将 stalker (Ruby gem) 作为守护进程运行
是否可以将 Ruby gem stalker 作为守护进程运行?类似stalk jobs.rb -d
。我应该只使用 stalk jobs.rb &
吗?
Is it possible to run the Ruby gem stalker as a daemon? Something like as stalk jobs.rb -d
. Should I just use stalk jobs.rb &
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用操作系统的启动系统来运行并重新生成该进程。
如果您使用的是 Ubuntu,一个简单的 Upstart 脚本的优点是您可以简单地编写脚本以留在前台(不进行守护进程、分叉、存储 PID 等)。当 Upstart 为您运行脚本时,它将负责将其作为守护进程运行。
这样,您就可以编写一个在前台运行的简单脚本以进行开发,让该脚本在生产环境中启动时启动,它可以依赖于其他启动脚本,最重要的是 - 您可以让 init 重新生成已终止的作业。
您可以让 Upstart 以您喜欢的任何用户身份运行该作业 - 因此,如果需要,您可以以该用户身份终止该作业,操作系统将很乐意为您重新生成它。
不再需要监视监视您工作的监视者。
You could use your OS's startup system to run and respawn the process for you.
If you're on Ubuntu, a simple Upstart script has the advantage that you can simply write the script to stay in the foreground ( do no daemonizing, forking, storing of PIDs etc). When Upstart runs the script for you, it will take care of running it as a daemon for you.
This way, you get to write a simple script that runs in the foreground for development, have the script startup at boot time in production, it can have dependencies on other startup scripts and best of all - you get init to respawn jobs that die.
You can get Upstart to run the job as any user you like - so you can kill the job as that user if required and the OS will happily respawn it for you.
No more watching the watcher who watches your job.
如果 stalker 本身不提供该选项,您可以尝试
daemonize
或类似的东西:http: //software.clapper.org/daemonize/
If stalker itself does not provide that option, you could try
daemonize
or something similar:http://software.clapper.org/daemonize/
您是否看过http://railscasts.com/episodes/130-monitoring-with -god
需要确保您的后台进程保持正常运行并且不使用太多资源?查看本集中所示的上帝宝石。
我用它来处理我的视频转码工作人员。看起来非常靠谱。
Have you had a look at http://railscasts.com/episodes/130-monitoring-with-god
Need to ensure your background processes stay up and running and don't use too many resources? Check out the god gem as shown in this episode.
I use it for handling my video transcode workers. It seems very reliable.