从应用程序服务器分叉延迟作业?
这是我希望延迟作业运行时的简单理想案例场景:
- 当第一个应用程序服务器(无论是通过 mongrel 还是乘客)启动时,它将启动我的延迟作业工作人员。
- 当最后一个运行的应用程序服务器终止时,它将杀死所有延迟的作业工作者。
第一部分(开始)是可行的,尽管我不确定“正确”或“最好”的方法是什么。只需对delayed_job start进行一个有条件的(在尚未运行的进程上)系统调用?
第二部分(终止)——嗯,我不确定它是否可行。绝对不知道如何实现这种效果。
有什么想法或想法吗?
您是否有另一种您认为最好的方式来开始/结束延迟工作的员工?
附带问题: 上面的主要问题是针对生产环境的——这是一个更困难的情况,因为有多个应用程序服务器同时运行。在开发环境中(保证只有一个应用程序服务器,而不是一组应用程序服务器)是否可以通过分叉一个子进程来运行延迟作业工作人员来轻松完成同样的事情,这些工作人员总是在父进程终止时终止?我该怎么做呢?
Here's my simple ideal case scenario for when I'd like delayed job to run:
- When the first application server (whether through mongrel or passenger) starts, it'll start my delayed job workers.
- When the last running application server terminates, it'll kill all the delayed job workers.
The first part (starting) is doable, although I'm not sure what the "right" or "best" way to do it is. Just make a conditional (on process not already running) system call to delayed_job start?
The second part (terminating) -- well, I'm not sure if it is doable or not. Definitely have no idea how this effect could be accomplished.
Any thoughts or ideas?
Is there another way that you start/end delayed job workers that you think is best?
Side question:
The main questions above are for the production environment -- a more difficult case because there are multiple app servers running at the same time. Could the same thing be easily done in the development environment (where there's guaranteed to only be one application server, not a cluster of them) by forking a child process to run the delayed job workers that would always terminate when the parent terminates? How would I go about doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你绝对可以用 god 来终止。
只需观察应用程序进程,当它们全部停止时,上帝就会触发回调。
You could definitely pull the terminating off with god.
Simply watch the app processes and god will fire a callback when they're all stopped.