Skip to content

Instantly share code, notes, and snippets.

@seamusabshere
Created July 28, 2010 16:15
Show Gist options
  • Select an option

  • Save seamusabshere/495083 to your computer and use it in GitHub Desktop.

Select an option

Save seamusabshere/495083 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
PRESUMPTIVE_RAILS_ROOT = '/data/data1/current'
Dir.chdir PRESUMPTIVE_RAILS_ROOT
require 'rubygems' # do this after changing dirs or else bundler won't be able to find .bundle
gem 'seamusabshere-daemon-spawn', '0.2.6' # otherwise we don't get timeout kill -9
require 'daemon_spawn'
PID_PATH = '/data/data1/shared/pids/delayed_job.pid'
LOG_PATH = '/data/data1/shared/log/delayed_job/delayed_job.log'
TIMEOUT = 90
SIGNAL = 'INT'
class DelayedJobWorker < DaemonSpawn::Base
def start(args)
require File.join('config', 'environment')
f = open LOG_PATH, (File::WRONLY | File::APPEND | File::CREAT)
f.sync = true
RAILS_DEFAULT_LOGGER.auto_flushing = true
RAILS_DEFAULT_LOGGER.instance_variable_set(:@log, f)
Delayed::Worker.logger = RAILS_DEFAULT_LOGGER
Delayed::Worker.new(:quiet => true).start
end
def stop
end
end
DelayedJobWorker.spawn!(:log_file => LOG_PATH,
:pid_file => PID_PATH,
:sync_log => true,
:working_dir => PRESUMPTIVE_RAILS_ROOT,
:singleton => true,
:timeout => TIMEOUT,
:signal => SIGNAL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment