Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start/stop return code with Daemons Ruby gem

Tags:

ruby

daemons

I've written some code that should run as a server and wrapped it with Daemons as Daemons.run('myserver.rb'). When I run it as ./daemon.rb start it works but it is not informative at all, i.e. if myserver.rb throws an exception I will not even know my server did not start, Daemons will exit with exit code 0. Is there any way to tell Daemons to return a non-zero exit code if the wrapped script fails to start? Or perhaps another way for me to know if my server started successfully?

like image 671
Andrii Yurchuk Avatar asked May 14 '26 08:05

Andrii Yurchuk


1 Answers

try

d=Daemons.run('myserver.rb')
exit d.applications.length > 0 ? 0 : 1
like image 78
Mike Corbin Avatar answered May 16 '26 08:05

Mike Corbin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!