-
-
Save cornet/1211303 to your computer and use it in GitHub Desktop.
Script to start/stop delayed_job
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make Rails 3 compatible