Sha256: 47c3ce31138b3d8cfa3b2736c41b5f82d3dc7e48117e54d45680535e067d0dc5

Contents?: true

Size: 938 Bytes

Versions: 14

Compression:

Stored size: 938 Bytes

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'

env, cmd = 'development', nil
ARGV.each do |arg|
  if arg =~ /RAILS_ENV\s*=\s*(\w+)/
    env = $1
  else
    cmd = arg
  end
end

unless %w{index start stop restart}.include?(cmd)
  puts "Usage: script/worker RAILS_ENV=production [start|stop|restart]"
  exit -1
end

dir = File.expand_path('.')

daemon_options = {
  :multiple   => false,
  :dir_mode   => :normal,
  :dir        => File.join(dir, 'log'),
  :backtrace  => true,
  # Create a worker.output to redirect STDOUT and STDERR
  :log_output => true,
}

ARGV.clear
ARGV << cmd

Daemons.run_proc('worker', daemon_options) do
  ARGV.clear

  Dir.chdir dir
  ENV['RAILS_ENV'] = RAILS_ENV = env
  require File.join('config', 'environment')

  require 'delayed/worker'
  begin
    require 'thinking_sphinx/deltas/delayed_delta'
  rescue LoadError
    # Ignore
  end

  puts "Starting worker..."

  Delayed::Worker.new.start
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
zena-1.1.1 bricks/worker/zena/worker
zena-1.1.0 bricks/worker/zena/worker
zena-1.0.0 bricks/worker/zena/worker
zena-1.0.0.rc3 bricks/worker/zena/worker
zena-1.0.0.rc2 bricks/worker/zena/worker
zena-1.0.0.rc1 bricks/worker/zena/worker
zena-0.16.9 bricks/worker/misc/worker
zena-1.0.0.beta3 bricks/worker/zena/worker
zena-0.16.8 bricks/worker/misc/worker
zena-1.0.0.beta2 bricks/worker/zena/worker
zena-1.0.0.beta1 bricks/worker/zena/worker
zena-0.16.7 bricks/worker/misc/worker
zena-0.16.6 bricks/worker/misc/worker
zena-0.16.5 bricks/worker/misc/worker