How would I start a shell daemon and then stop it from within the same Ruby script?
To be more specific, I'd like my Ruby script to:
rails server
| shotgun
| etc... ).All embracing solutions that are supported in ruby 1.8/1.9 and unix/windows are preferred. (I read fork
for instance does not work on Windows).
Create configurations for script files and select Shell Script. Under Execute, select the Script file option. Specify the path to the script file and options that you want to pass to the script when it is launched. You can also change the interpreter for running the script and additional options for the interpreter.
A daemon (also known as background processes) is a Linux or UNIX program that runs in the background. Almost all daemons have names that end with the letter "d". For example, httpd the daemon that handles the Apache server, or, sshd which handles SSH remote access connections.
I can highly recommend the Ruby Daemons gem. I think it has all the functionality you need.
Check the section 3 of its README, and pay particular attention to Daemons.call method that allows to daemonize arbitrary code (in which you could just Kernel.system
an app).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With