Command-line ruby: Spawn and control multiple daemons

I'm new to Ruby and could use some advice on what approach I should take. I need a command line script that can spawn two daemons and stop them when asked. Ideally there'd be 3 files in total.


I'd start it from the command line like this:
$ ./loader.rb start

It would spawn a daemon each for server.rb and server_2.rb, and then exit (leaving the daemons running). I could then run 'loader.rb' at any point to shut down the two daemons:

$ ./loader.rb stop

I've been looking at the "Daemons" Gem, which seems like a good approach. I could use some help w/ the syntax though. I think I need to use "", but I'm not clear on how to source in code from other files with it.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Andrew DoadesIT TechnicianCommented:
Used to use this in an old rails app;

require 'rubygems'
require 'daemons''wp_cron.rb', :app_name => 'wp_cron', :dir_mode => :script, :log_output => true)

Open in new window

Hope this helps..

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zumpoofAuthor Commented:
This is exactly what I'm looking for. Thanks, doades!
zumpoofAuthor Commented:
One more quick question- I have two daemons, but it seems that only the first '' call gets executed. The second one gets ignored (I checked w/ 'ps -ax'). Is there a way to spawn two daemons instead of just one?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.