Created
September 15, 2010 17:22
-
-
Save seamusabshere/581086 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| PRESUMPTIVE_RAILS_ROOT = '/data/my_app/current' | |
| Dir.chdir PRESUMPTIVE_RAILS_ROOT | |
| require "rubygems" | |
| require "bundler/setup" | |
| require 'daemon_spawn' # use 0.4.0 | |
| PID_PATH = '/data/my_app/shared/pids/delayed_job.pid' | |
| LOG_PATH = '/data/my_app/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) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the logging stuff is rather clumsy, i recognize that