ruby on rails delajed_job failing with rvm

Posted by mottalrd on Stack Overflow See other posts from Stack Overflow or by mottalrd
Published on 2012-07-01T03:09:45Z Indexed on 2012/07/01 3:15 UTC
Read the original article Hit count: 376

Filed under:
|
|

I have delayed_job installed and I start the daemon to run the jobs with this ruby script

require 'rubygems'
require 'daemon_spawn'
$: << '.'

RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))

class DelayedJobWorker < DaemonSpawn::Base
  def start(args)
    ENV['RAILS_ENV'] ||= args.first || 'development'
    Dir.chdir RAILS_ROOT
    require File.join('config', 'environment')

    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)

If I run the command with rvmsudo it works perfectly
If I simply use the ruby command without rvm it fails and this is the output, but I have no idea why this happens. Could you give me some clue?

Thank you

user@mysystem:~/redeal.it/application$ ruby script/delayed_job start production
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:16:in `kill': Operation not permitted (Errno::EPERM)
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:16:in `alive?'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:125:in `alive?'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:176:in `block in start'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:176:in `select'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:176:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:165:in `spawn!'
from script/delayed_job:37:in `<main>'

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about rvm