Skip to content

Instantly share code, notes, and snippets.

@voldy
Forked from akmathur/delayed_job
Created May 3, 2010 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voldy/387848 to your computer and use it in GitHub Desktop.
Save voldy/387848 to your computer and use it in GitHub Desktop.
script/delayed_job
#!/usr/bin/env ruby
# -*- ruby -*-
require 'rubygems'
require 'daemon-spawn'
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
class DelayedJobWorker < DaemonSpawn::Base
def start(args)
ENV['RAILS_ENV'] ||= args.first || 'development'
Dir.chdir RAILS_ROOT
require File.join('config', 'environment')
Delayed::Worker.new.start
end
def stop
system("kill `cat /var/www/apps/jeengle/shared/pids/delayed_job.pid`")
end
end
DelayedJobWorker.spawn!(:log_file => File.join("/var/www/apps/jeengle/shared/", "log", "delayed_job.log"),
:pid_file => File.join("/var/www/apps/jeengle/shared/", 'pids', 'delayed_job.pid'),
:sync_log => true,
:working_dir => RAILS_ROOT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment