Skip to content

Instantly share code, notes, and snippets.

@cornet
Forked from akmathur/delayed_job
Created September 12, 2011 13:53
Show Gist options
  • Save cornet/1211303 to your computer and use it in GitHub Desktop.
Save cornet/1211303 to your computer and use it in GitHub Desktop.
Script to start/stop delayed_job
#!/usr/bin/env ruby
# -*- ruby -*-
require 'rubygems'
require 'daemon_spawn'
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
class DelayedJobWorker < DaemonSpawn::Base
def start(args)
ENV['RAILS_ENV'] ||= args.first || 'development'
Dir.chdir Rails.root
Delayed::Worker.new.start
end
def stop
system("kill `cat #{Rails.root}/tmp/pids/delayed_job.pid`")
end
end
DelayedJobWorker.spawn!(:log_file => File.join(Rails.root, "log", "delayed_job.log"),
:pid_file => File.join(Rails.root, 'tmp', 'pids', 'delayed_job.pid'),
:sync_log => true,
:working_dir => Rails.root)
@cornet
Copy link
Author

cornet commented Sep 12, 2011

Make Rails 3 compatible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment