Reputation: 6027
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
Upvotes: 1
Views: 1273
Reputation: 4930
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.
Upvotes: 2
Reputation: 442
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.
Upvotes: 0