gpt4 book ai didi

php - Supervisord 仅生成 1 个实例

转载 作者:可可西里 更新时间:2023-11-01 12:34:16 26 4
gpt4 key购买 nike

我有以下问题:

我想以 gearman worker 的身份运行 php 脚本,或者准确地说,以 5 个 worker 的身份运行。这是我的 supervisord.conf 添加:

[program:gearman-test-worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /path/to/gearman-jobs/worker.php
numprocs=5
directory=/path/to/gearman-jobs/
stdout_logfile=/var/log/gearman-job-server/supervisord.log
environment=GEARMAN_USER=gearman
autostart=true
autorestart=true
user=gearman
stopsignal=KILL

当我启动它时 supervisord -n(或在守护进程模式下)它只会产生 1 个实例而不是 5 个。消息看起来很好

[root@pc113 gearman-jobs]# supervisord -n
2013-09-03 14:24:58,775 CRIT Supervisor running as root (no user in config file)
2013-09-03 14:24:58,789 INFO /var/tmp/supervisor.sock:Medusa (V1.1.1.1) started at Tue Sep 3 14:24:58 2013
Hostname: <unix domain socket>
Port:/var/tmp/supervisor.sock
2013-09-03 14:24:58,850 CRIT Running without any HTTP authentication checking
2013-09-03 14:24:58,850 INFO supervisord started with pid 8722
2013-09-03 14:24:58,853 INFO spawned: 'gearman-test-worker' with pid 8723
2013-09-03 14:24:59,858 INFO success: gearman-test-worker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

并且没有提示为什么它只生成一个实例。你能帮忙吗?

最佳答案

我觉得问题很简单,“numprocs”配置项是v3.0才引入的,见http://supervisord.org/configuration.html .

我能够在现有的 CentOS 6.x 系统上重现您的问题,该系统在发布方面明显落后。

# supervisord -n
2013-09-14 17:19:52,708 CRIT Supervisor running as root (no user in config file)
2013-09-14 17:19:52,724 INFO /var/tmp/supervisor.sock:Medusa (V1.1.1.1) started at Sat Sep 14 17:19:52 2013
Hostname: <unix domain socket>
Port:/var/tmp/supervisor.sock
2013-09-14 17:19:52,809 CRIT Running without any HTTP authentication checking
2013-09-14 17:19:52,809 INFO supervisord started with pid 21521
2013-09-14 17:19:52,817 INFO spawned: 'gearman-test-worker' with pid 21522
2013-09-14 17:19:53,820 INFO success: gearman-test-worker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

# rpm -qa | grep supervisor
supervisor-2.1-8.el6.noarch

# uname -a
Linux dev26.sumilux.com 2.6.32-279.5.1.el6.i686 #1 SMP Tue Aug 14 21:14:52 UTC 2012 i686 i686 i386 GNU/Linux

如果我将 supervisor 包升级到 3.x(实际上是通过切换到一个古老的 Fedora 系统),一切都按预期工作(我设置了 3 个工作人员而不是 5 个)。

# supervisord -n
2013-09-14 17:24:56,205 CRIT Supervisor running as root (no user in config file)
2013-09-14 17:24:56,251 INFO RPC interface 'supervisor' initialized
2013-09-14 17:24:56,252 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2013-09-14 17:24:56,252 INFO supervisord started with pid 20889
2013-09-14 17:24:57,258 INFO spawned: 'gearman-test-worker_00' with pid 20890
2013-09-14 17:24:57,263 INFO spawned: 'gearman-test-worker_01' with pid 20891
2013-09-14 17:24:57,269 INFO spawned: 'gearman-test-worker_02' with pid 20892
2013-09-14 17:24:58,271 INFO success: gearman-test-worker_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2013-09-14 17:24:58,271 INFO success: gearman-test-worker_01 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2013-09-14 17:24:58,272 INFO success: gearman-test-worker_02 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

# rpm -qa | grep supervisor
supervisor-3.0-0.5.a10.fc14.noarch

关于php - Supervisord 仅生成 1 个实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18631983/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com