File: delayed_job.eye

package info (click to toggle)
ruby-eye 0.7-5.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 672 kB
  • sloc: ruby: 5,003; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 658 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
cwd = File.expand_path(File.join(File.dirname(__FILE__), %w[ ../ ../ ]))

config_path = File.join(cwd, %w{ config dj.yml } )

workers_count = if File.exist?(config_path)
  YAML.load_file(config_path).try(:[], :workers) || 5
else
  5
end

Eye.application 'delayed_job' do
  working_dir cwd
  stop_on_delete true

  group 'dj' do
    chain grace: 5.seconds

    (1 .. workers_count).each do |i|
      process "dj-#{i}" do
        pid_file "tmp/pids/delayed_job.#{i}.pid"
        start_command "rake jobs:work"
        daemonize true
        stop_signals [:INT, 30.seconds, :TERM, 10.seconds, :KILL]
        stdall "log/dj-#{i}.log"
      end
    end
  end
end