Sha256: 94972e59c595922431a6560d66fb700bc831e2e34b3f10b69deb5c2b34478e66

Contents?: true

Size: 968 Bytes

Versions: 6

Compression:

Stored size: 968 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'
    require 'thinking_sphinx/deltas/delayed_delta'
  rescue LoadError
    # Ignore
  end

  puts "Starting worker..."

  Delayed::Worker.new.start
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zena-1.2.3 bricks/worker/zena/worker
zena-1.2.2 bricks/worker/zena/worker
zena-1.2.1 bricks/worker/zena/worker
zena-1.2.0 bricks/worker/zena/worker
zena-1.1.3 bricks/worker/zena/worker
zena-1.1.2 bricks/worker/zena/worker