Created
September 13, 2019 16:06
-
-
Save adamruzicka/7d80f82a61790c15fb199abbd9a21aca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'daemons' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'daemons' | |
options = { | |
:multiple => true, | |
:dir_mode => :normal, | |
:log_dir => '/tmp/daemons/log', | |
:monitor => true, | |
:log_output => true, | |
:monitor_interval => 30 | |
} | |
5.times do | |
Daemons.run_proc('myproc.rb', options) do | |
loop do | |
puts "I am #{Process.pid}" | |
sleep(5) | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ps -ef | grep myproc.rb | |
aruzicka 21079 7950 0 18:03 pts/2 00:00:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn myproc.rb | |
$ bundle exec ruby runme.rb start | |
$ ps -ef | grep myproc.rb | |
aruzicka 21346 1 1 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21347 1 1 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21351 1 1 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21352 1 1 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21355 1 1 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21359 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21360 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21364 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21365 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21367 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21387 7950 0 18:04 pts/2 00:00:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn myproc.rb | |
$ bundle exec ruby runme.rb restart | |
$ bundle exec ruby runme.rb restart | |
myproc.rb: trying to stop process with pid 21351... | |
myproc.rb: trying to stop process with pid 21355...myproc.rb: trying to stop process with pid 21365... | |
myproc.rb: trying to stop process with pid 21360... | |
myproc.rb: trying to stop process with pid 21346... | |
myproc.rb: process with pid 21360 successfully stopped. | |
myproc.rb: process with pid 21351 successfully stopped. | |
myproc.rb: process with pid 21365 successfully stopped. | |
myproc.rb: process with pid 21355 successfully stopped. | |
myproc.rb: process with pid 21346 successfully stopped. | |
myproc.rb: process with pid 21732 started. | |
myproc.rb: process with pid 21729 started. | |
myproc.rb: process with pid 21727 started. | |
myproc.rb: process with pid 21728 started. | |
myproc.rb: process with pid 21734 started. | |
myproc.rb: trying to stop process with pid 21734... | |
myproc.rb: trying to stop process with pid 21729... | |
myproc.rb: trying to stop process with pid 21728... | |
myproc.rb: trying to stop process with pid 21727... | |
myproc.rb: trying to stop process with pid 21732... | |
myproc.rb: process with pid 21729 successfully stopped.myproc.rb: process with pid 21727 successfully stopped. | |
myproc.rb: process with pid 21732 successfully stopped.myproc.rb: process with pid 21734 successfully stopped. | |
myproc.rb: process with pid 21728 successfully stopped. | |
myproc.rb: process with pid 21758 started.myproc.rb: process with pid 21749 started. | |
myproc.rb: process with pid 21757 started. | |
myproc.rb: process with pid 21760 started. | |
myproc.rb: process with pid 21761 started. | |
myproc.rb: trying to stop process with pid 21758... | |
myproc.rb: trying to stop process with pid 21757...myproc.rb: trying to stop process with pid 21761...myproc.rb: trying to stop process with pid 21749... | |
myproc.rb: trying to stop process with pid 21760... | |
myproc.rb: process with pid 21758 successfully stopped. | |
myproc.rb: process with pid 21761 successfully stopped. | |
myproc.rb: process with pid 21760 successfully stopped. | |
myproc.rb: process with pid 21757 successfully stopped. | |
myproc.rb: process with pid 21749 successfully stopped. | |
myproc.rb: process with pid 21787 started. | |
myproc.rb: process with pid 21786 started. | |
myproc.rb: process with pid 21791 started. | |
myproc.rb: process with pid 21793 started. | |
myproc.rb: process with pid 21792 started. | |
myproc.rb: trying to stop process with pid 21786... | |
myproc.rb: trying to stop process with pid 21792... | |
myproc.rb: trying to stop process with pid 21787... | |
myproc.rb: trying to stop process with pid 21793... | |
myproc.rb: trying to stop process with pid 21791... | |
myproc.rb: process with pid 21786 successfully stopped. | |
myproc.rb: process with pid 21792 successfully stopped. | |
myproc.rb: process with pid 21793 successfully stopped. | |
myproc.rb: process with pid 21787 successfully stopped. | |
myproc.rb: process with pid 21791 successfully stopped. | |
myproc.rb: process with pid 21828 started. | |
myproc.rb: process with pid 21824 started. | |
myproc.rb: process with pid 21826 started. | |
myproc.rb: process with pid 21830 started. | |
myproc.rb: process with pid 21835 started. | |
myproc.rb: trying to stop process with pid 21839...myproc.rb: trying to stop process with pid 21826...myproc.rb: trying to stop process with pid 21830...myproc.rb: trying to stop process with pid 21835...myproc.rb: trying to stop process with pid 21824... | |
myproc.rb: process with pid 21826 successfully stopped. | |
myproc.rb: process with pid 21830 successfully stopped. | |
myproc.rb: process with pid 21839 successfully stopped. | |
myproc.rb: process with pid 21824 successfully stopped. | |
myproc.rb: process with pid 21835 successfully stopped. | |
myproc.rb: process with pid 21867 started. | |
myproc.rb: process with pid 21873 started. | |
myproc.rb: process with pid 21874 started. | |
myproc.rb: process with pid 21876 started. | |
myproc.rb: process with pid 21879 started. | |
$ $ ps -ef | grep myproc.rb | |
aruzicka 21347 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21352 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21359 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21367 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21725 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21733 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21735 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21736 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21763 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21764 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21765 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21766 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21794 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21795 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21798 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21799 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21825 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21828 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21831 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21832 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21833 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21834 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21846 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21847 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21851 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21867 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21870 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21873 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21874 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21875 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21876 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21878 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21879 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21880 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21881 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21900 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21902 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21909 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21910 1 0 18:04 ? 00:00:00 myproc.rb | |
$ ps -ef | grep myproc.rb | grep monitor | wc -l | |
26 | |
$ ps -ef | grep myproc.rb | grep -v monitor | wc -l | |
14 | |
$ bundle exec ruby runme.rb stop | |
myproc.rb: trying to stop process with pid 21910... | |
myproc.rb: trying to stop process with pid 21879... | |
myproc.rb: trying to stop process with pid 21867... | |
myproc.rb: trying to stop process with pid 21873... | |
myproc.rb: trying to stop process with pid 21876... | |
myproc.rb: process with pid 21879 successfully stopped. | |
myproc.rb: process with pid 21910 successfully stopped. | |
myproc.rb: process with pid 21867 successfully stopped. | |
myproc.rb: process with pid 21873 successfully stopped. | |
myproc.rb: process with pid 21876 successfully stopped. | |
$ ps -ef | grep myproc.rb | |
aruzicka 21347 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21352 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21359 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21367 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21725 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21733 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21735 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21736 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21763 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21764 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21765 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21766 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21794 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21795 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21798 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21799 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21825 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21828 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21831 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21832 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21833 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21834 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21846 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21847 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21851 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21870 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21874 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21878 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21880 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21881 1 0 18:04 ? 00:00:00 myproc.rb_monitor | |
aruzicka 21900 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21902 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 21909 1 0 18:04 ? 00:00:00 myproc.rb | |
aruzicka 22320 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22321 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22328 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22329 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22336 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22337 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22341 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22345 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22355 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22359 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22374 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22376 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22380 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22381 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22384 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22386 1 0 18:05 ? 00:00:00 myproc.rb | |
aruzicka 22387 1 0 18:05 ? 00:00:00 myproc.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment