在后台运行 Gearman Worker
我正在使用 Ubuntu Natty 和 PHP 5.3.8。我刚刚让 Gearman 在我的服务器上工作。
我用 PHP 手册中的一些脚本做了一些测试,一切正常。
但是,我想知道是否有一种方法可以在后台运行工作人员并对其进行监视,以便当我转向多工作人员情况时,我可以跟踪我有多少工作人员在职的。
通常,我必须打开两个终端,一个用于工作人员,一个用于客户。执行 php 脚本后,worker 的状态实际上会“卡住”。
提前致谢。
I'm using Ubuntu Natty with PHP 5.3.8. I just got Gearman working on my server.
I did a few tests with some scripts I got off the PHP Manual, and everything works ok.
However, I'd like to know if there's a way I can run the worker in the background, and also monitor it so that when I move to a multi-worker situation, I can keep track of just how many workers I've got working.
Usually, I would have to open two terminals, one for the worker and one for the client. The one for the worker becomes 'stuck' in effect after the php script is executed.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好的。我找到了解决我之前问题的方法。它涉及使用 Supervisord 来取消齿轮工的工作。
以下是如何安装 Supervisord
以下是如何配置它(首先从 此处 获取初始化脚本并将其保存到 < code>/etc/init.d/supervisord),然后执行以下操作:
然后您需要更新supervisor.conf文件以告诉supervisord您想要作为守护进程运行哪个命令(当然,这将是你的齿轮工工人)。以下只是您要添加到supervisord.conf 文件中的内容的示例,您需要根据自己的具体情况进行更新。
完成后,启动supervisord,即
/etc/init.d/supervisord start
。执行此操作后,您的 Gearman 工作线程现在处于活动状态,您现在可以通过命令行或使用浏览器运行 gearman 客户端。
我希望这有帮助。
Ok. I found a solution to my earlier problem. It involves using Supervisord to deamonize the gearman worker(s).
Here's how to install Supervisord
Here's how to configure it (first get an init script from here and save it to
/etc/init.d/supervisord
), then do the following:You then need to update your supervisor.conf file to tell supervisord which command you want to run as a daemon (of course, this would be your gearman worker). Below is just a sample of what you would add to your supervisord.conf file, you'll need to update it to your own specific situation.
When you're done, then start supervisord i.e.
/etc/init.d/supervisord start
.Once you do this, your Gearman worker is now active and you can now run your gearman client via the command line or with your browser.
I hope this helps.
对于后台工作人员,您可以使用 Brian Moon 的 GearmanManager
https://github.com/brianlmoon/GearmanManager
For background workers you can use GearmanManager by Brian Moon
https://github.com/brianlmoon/GearmanManager
另一种选择是使用
screen
将工作人员将任务放入独立的 shell 中:Another option is to use
screen
to put the worker task into a detached shell: