Command-line ruby: Spawn and control multiple daemons
Posted on 2013-10-19
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 "Daemons.call", but I'm not clear on how to source in code from other files with it.