再次查看链接到的文档中的示例:
God.watch do |w|
w.name = "simple"
w.start = "ruby /full/path/to/simple.rb"
w.keepalive
end
CTRL-C
这个
god
你杀死你的背景的过程
ruby
过程。即使杀人后你也能看到
上帝啊
ps aux | grep ruby
最后,
puts
做
上帝啊
直到
红宝石
过程
simple.rb
# Confirm no running ruby processes, otherwise kill the processes and re-verify
ps aux | grep ruby
# Start the daemon
god -c simple.god -D
切换到新shell并运行:
ps aux | grep ruby
foo 51279 0.0 0.1 4322084 11888 ?? Ss 12:46AM 0:00.09 ruby /Users/foo/simple.rb
foo 51241 0.0 0.2 4343944 26208 s000 S+ 12:46AM 0:00.45 ruby /Users/foo/.rvm/gems/ruby-2.6.0-preview2/bin/god -c simple.god -D
# Kill the process for simple.rb, which causes god to dump the output to the log and restart it
kill 51279
# Verify log file contains expected output
cat myprocess.log
Hello
Hello
Hello
Hello
上帝啊
. 有很多,答案都在那里。