Permalink
Browse files

Not starting delayed_job in test environment - perhaps helpful for #265

  • Loading branch information...
1 parent 3f297e2 commit c89d12b650342bba378eda92e46dbba72597d202 @augustf augustf committed Dec 20, 2012
Showing with 20 additions and 18 deletions.
  1. +20 −18 config/initializers/14-delayed_job.rb
@@ -1,22 +1,24 @@
#NB: This code will not work if more than one worker process is being used
#Additionally, the -m argument can be used to spawn a monitor process alongside the daemon(s)
-
-DELAYED_JOB_PID_PATH = "#{Rails.root}/tmp/pids/delayed_job.pid"
-
-def start_delayed_job
- Thread.new do
- `ruby script/delayed_job start`
+unless Rails.env.test?
+ DELAYED_JOB_PID_PATH = "#{Rails.root}/tmp/pids/delayed_job.pid"
+
+ def start_delayed_job
+ Thread.new do
+ `ruby script/delayed_job start`
+ end
+ end
+
+ def daemon_is_running?
+ pid = File.read(DELAYED_JOB_PID_PATH).strip
+ Process.kill(0, pid.to_i)
+ true
+ rescue Errno::ENOENT, Errno::ESRCH # file or process not found
+ false
+ end
+
+ if ConcertoConfig[:autostart_delayed_job] == "true"
+ start_delayed_job unless daemon_is_running?
end
-end
-
-def daemon_is_running?
- pid = File.read(DELAYED_JOB_PID_PATH).strip
- Process.kill(0, pid.to_i)
- true
-rescue Errno::ENOENT, Errno::ESRCH # file or process not found
- false
-end
-if ConcertoConfig[:autostart_delayed_job] == "true"
- start_delayed_job unless daemon_is_running?
-end
+end

0 comments on commit c89d12b

Please sign in to comment.