I can't run my Rails application with daemons gem

可紊 提交于 2019-12-11 11:52:18

问题


I want to use Daemons gem with my Rails project so I can easily monitore it with Monit, this gem will allow me to create PIDs and use commands like start and stop .

Anyways it seems I can't use it with rails somehow, I create a file and named it admin :

require 'rubygems'
require 'daemons'

ROOT_PATH = File.expand_path("#{File.dirname __FILE__}/../")

require "#{ROOT_PATH}/config/environment"

Daemons.run("#{ROOT_PATH}/script/rails" , 
    :dir_mode => :system, 
    :log_output => true 
)

When I try to run it with :

bundle exec ./bin/admin run -- s

I get this error :

/Users/info/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config.
=> Booting WEBrick
=> Rails 3.0.5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
configuration /config.ru not found
Exiting

The config.ru file is there for sure. and I can run the application when I try to do it manually with command line, but for some reason I can daemonize the rails app .

I would appreciate any help since I spent all my day trying to iron this out .

Cheers


回答1:


May it be because daemons is not running the server in your application root directory ?

UPDATE

To launch Rails server from another path than your root app directory, use the -c option of rails server command which need the exact path to your config.ru file.




回答2:


I know this doesn't directly solve your issue with daemons, but if you're on linux you can use start-stop-daemon to basically do the same thing. And you wouldn't need a script for it, just a one liner in your monit config which uses start-stop-daemon to daemonize the process.



来源:https://stackoverflow.com/questions/13301174/i-cant-run-my-rails-application-with-daemons-gem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!