守护进程生成:gem_original_require:没有要加载的文件--daemon-spawn(加载错误)

发布于 2024-09-25 14:29:49 字数 1132 浏览 3 评论 0 原文

我正在尝试使用 daemon-spawn gem 运行守护进程。 这是delayed_delta守护进程的代码,


#file - script/dj
#!/usr/bin/env ruby
# -*- ruby -*-
require 'rubygems'
require 'daemon-spawn'

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

class DelayedJobWorker  ENV['MIN_PRIORITY'],
      :max_priority => ENV['MAX_PRIORITY']
    ).start
  end

  def stop
    system("kill `cat #{RAILS_ROOT}/tmp/delayed_job.pid`")
  end
end

DelayedJobWorker.spawn!(:log_file => File.join(RAILS_ROOT, "log", "delayed_job.log"),
                        :pid_file => File.join(RAILS_ROOT, 'tmp', 'delayed_job.pid'),
                        :sync_log => true,
                        :working_dir => RAILS_ROOT)

当我运行时,它在我的本地机器上运行良好

ruby script/dj start
, but when I run it in cloud server, it throws a weird error


/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- daemon-spawn (LoadError)
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from script/dj:4

有什么想法吗?有什么帮助吗?

I am trying to run daemon process using daemon-spawn gem.
Here is the code for delayed_delta daemon process


#file - script/dj
#!/usr/bin/env ruby
# -*- ruby -*-
require 'rubygems'
require 'daemon-spawn'

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

class DelayedJobWorker  ENV['MIN_PRIORITY'],
      :max_priority => ENV['MAX_PRIORITY']
    ).start
  end

  def stop
    system("kill `cat #{RAILS_ROOT}/tmp/delayed_job.pid`")
  end
end

DelayedJobWorker.spawn!(:log_file => File.join(RAILS_ROOT, "log", "delayed_job.log"),
                        :pid_file => File.join(RAILS_ROOT, 'tmp', 'delayed_job.pid'),
                        :sync_log => true,
                        :working_dir => RAILS_ROOT)

This works well in my local machine when I run

ruby script/dj start

, but when I run it in cloud server, it throws a weird error


/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- daemon-spawn (LoadError)
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from script/dj:4

any idea? any help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

短暂陪伴 2024-10-02 14:29:49

我遇到了同样的问题,最初我有 alexvollmer-daemon-spawn 但我无法运行更多数量的进程,所以我卸载了它并安装了 daemon-spawn gem这对我有用。

注意:当您使用 alexvollmer-daemon-spawn gem 时,请使用 require daemon-spawn,但当您使用 daemon-spawn gem 时,请使用 require daemon_spawn(使用下划线)。

I had the same problem, initially i had alexvollmer-daemon-spawn but i was unable to run more number of processes, So i uninstalled it and i installed daemon-spawn gem which worked for me.

Note: When you use alexvollmer-daemon-spawn gem use require daemon-spawn, but when you use daemon-spawn gem use require daemon_spawn (use underscore).

黑白记忆 2024-10-02 14:29:49

有同样的问题。尝试

require 'daemon_spawn'

使用下划线。

Had the same problem. Try

require 'daemon_spawn'

I.e. use an underscore.

一抹苦笑 2024-10-02 14:29:49

看起来云服务器没有 daemon-spawn gem。您在 Heroku 上使用捆绑器还是其他东西?

Looks like the cloud server doesn't have the daemon-spawn gem. Are you using bundler on Heroku or something else?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文