Search code examples
ruby-on-railsrubyubuntumonit

Running Mailman script as a service in Ubuntu/Monit


I have setup a mailman script in my rails app to download and process emails. This is working fine.

The script is located in the scripts directory of the rails app.

I need this script to run upon deployment, via monit (which I am using for other services).

I am not sure how to configure monit to run this particular script (as it has no start/stop functions etc).

Using Ubuntu 12.04 on the server.


Solution

  • Pretty outdated question, but in case somebody is looking for the same - you can use gem Daemons and create a wrapper script, something like:

    #!/usr/bin/env ruby
    require 'daemons'
    
    Daemons.run('script/mailman_server')
    

    Then you get start and stop commands and can do:

    bundle exec script/mailman_daemon start
    

    and

    bundle exec script/mailman_daemon stop