Process.daemon 与使用 nohup 运行 Ruby 脚本的比较&
我有一个 Ruby 1.9 脚本,我想将其作为长时间运行的后台进程运行。
看起来我可以选择在脚本内调用 Process.daemon 来守护它,或者我可以使用 shell 的 & 符号在后台运行脚本并在我注销后保持它运行通过在命令前加上 nohup 前缀来服务器。
哪种方式更好?
I have a Ruby 1.9 script that I want to run as a long-running background process.
It looks like I have a choice between calling Process.daemon
inside the script to daemonize it, or I can just run the script in the background using a shell's ampersand and keep it running after I log out of the server by prefixing the command with nohup
.
Which way is better?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Process.daemon 似乎是一种更干净、更直接的方法,特别是如果您可以将其转变为在引导期间启动的成熟守护进程。
Process.daemon
seems like a more clean and straightforward way, especially if this is something you would ever way to turn into a full-fledged daemon that is started during boot.