I would suggest you to use signals to communicate to your running process.
With this approach it wont matter what framework you are using,
though my best recommandation is Espresso Framework.
So here is the deal. There are a lot of signals you can send to your process via kill
interface.
Signals can be sent from command line of from another Ruby process.
All you need is to catch/trap sent signal(s) inside your app.
Example: inside controlled process:
# build your app
Signal.trap("USR1") do
# do some stuff here
end
Signal.trap("USR2") do
# do another stuff here
end
# run your app
When you start your app make sure to get its PID
.
Having the PID
you can send signals to your app via kill
(no, it wont kill your app unless you send an explicit signal for this).
Then from another Ruby process you can do:
Process.kill "USR1", PID
Or directly from command line:
kill USR2 PID
And your app will catch/trap send signal and do corresponding stuff.
Just make sure to replace PID
with real Process ID of controlled app.
This practice are successfully used by Unicorn web server.
Here is a list of signals:
http://en.wikipedia.org/wiki/Unix_signal
Some insight on working with signals in Ruby:
https://jellyjelly.net/blog/2010/04/27/unix-signal-programming-in-ruby/