How to make a Ruby script into a daemon process

Use Daemons.


gem install daemons

2. Then, say you have myserver.rb, create a control script, myserver_control.rb, like this:

require 'rubygems'        # if you use RubyGems
require 'daemons''myserver.rb')

3. and use it from the console like this:

$ ruby myserver_control.rb start
    (myserver.rb is now running in the background)
$ ruby myserver_control.rb restart
$ ruby myserver_control.rb stop


Leave a Reply

Your email address will not be published. Required fields are marked *