简体   繁体   中英

init.d script generator for ruby processes?

I have some ruby processes, and for development I've been using foreman to manage the processes, now in production I want to export the processes and run it in /etc/init.d directory.

Is there any tool that can help with that, by creating the scripts and the related PID to /var/run ? I tried to use foreman export feature to do so, but it didn't work to do that, since it can do something for inittab or upstart but not init.d.

Any help would be highly appreciated

mm it seems no tool to create that , foreman can export inittabs, upstart but not init.d, the only way is to modify the file :

/etc/init.d/skeleton 

You will need to slightly modify it, and then :

chmod +x /etc/init.d/process_name 
sudo update-rc.d process_name defaults
sudo /etc/init.d/process_name (start| stop| reload ) 

Done . :)

Another Answer could be with using https://github.com/ghazel/daemons gem .

require 'daemons'
require 'process'

Daemons.run('process.rb')

Once the script is done, just call it from your command line:

ruby process.rb run|start|stop|restart

This config will generate a "process.pid" file under "/var/run" and you can use monit to watch over the process by using this file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM