0

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!

1 Answer 1

6

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
Sign up to request clarification or add additional context in comments.

3 Comments

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!
Sorry not sure how to do that after server stops.
Posted a separate question. Thank you very much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.