为什么我的delayed_job的失败没有RVM?(Why does my delayed_job

2019-09-18 20:48发布

我有一个delayed_job安装,我开始守护进程来运行这个Ruby脚本的工作:

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)

如果我运行命令rvmsudo它完美。

如果我只是使用了Ruby命令而不RVM失败,这是输出。 我不知道为什么会这样。 你能给我一些线索?

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>'

Answer 1:

你有一个权限问题。

简单来说:你有一个延迟工作在另一个用户运行(proprably root因使用rvmsudo )和守护产卵试图杀死它。 你会得到一个Operation not permitted

试着用rvmsudo第一杀的delayed_job,确保它没有运行(试ps aux ),然后尝试启动没有rvmsudo

它应该工作。



Answer 2:

首先,来看看共享/的PID / delayed_job.pid,看看进程正在运行。 在我的情况下,它看上去就像是关闭不干净,被留在原地pid文件。 部署脚本想杀不存在的进程,并给予该权限错误。

我已删除delayed_job.pid和部署成功。



文章来源: Why does my delayed_job fail without RVM?