views:

146

answers:

1

I want to start my daemon with my application.

In the command line, I can write something like lib/daemons/mydaemon_ctl start to start up my daemon, but I have to do this manually. I want the daemon to start when I start my server (i.e. when the initializer files are loaded).

Is there a ruby command for executing a command line? Something like exec "lib/daemons/mydaemon_ctl start"?

Thanks!

+2  A: 

Seems you just want to run shell commands in ruby code, well you can use system or backtick(`)

system 'ls' # will return ls output in *nix
`dir` # will return dir output in windows
Ed
Perfect! This is exactly what I'm looking for.Turns out the daemon keeps running even when the server stops. Where would I put a command that I want to run when the server stops? (to stop the daemon?) Thank you very much!
yuval
Sorry not sure how to do that after server stops.
Ed
Posted a separate question. Thank you very much!
yuval