gpt4 book ai didi

laravel - docker : Worker keep exiting and respawn and 99% CPU

转载 作者:IT王子 更新时间:2023-10-29 06:12:28 26 4
gpt4 key购买 nike

Supervisord 无法让 redis worker 继续运行,我的 worker 仍然以状态代码 12 退出并重生。我的 redis 容器在应用程序的 docker 网络上(主管所在的位置)

我遵循 laravel 的文档:https://laravel.com/docs/5.8/queues#supervisor-configuration

我试图守护命令和一些代码更新我也将我的 Debian 更新为 Stretch 和 Docker我在本地测试了所有这些,一切正常......

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/artisan queue:work redis --sleep=3 --tries=3
autostart=true
autorestart=true
user=www-data
numprocs=8
priority=10
redirect_stderr=true
stdout_logfile=/var/log/worker.log
api:
image: gitlab.ladechetterieduweb.com:5555/lddw/backend:latest
container_name: backend-lddw-develop
restart: always
working_dir: /var/www
volumes:
- ./config/api:/var/env
- ./app/storage:/var/www/storage
- ./logs/laravel:/var/www/storage/logs
- ./logs/supervisord:/var/log
depends_on:
- db
command: /bin/bash -c "cp /var/env/.env /var/www/.env && supervisord -c /etc/supervisord.conf --nodaemon"
networks:
- app-network

redis:
image: redis:5.0.3-stretch
restart: always
ports:
- 6379:6379
container_name: redis-lddw-develop
volumes:
- redis_data:/data
- ./config/redis:/usr/local/etc/redis
command: /bin/bash -c "cp /usr/local/etc/redis/rc.local /etc/rc.local && redis-server --appendonly yes"
networks:
- app-network

2019-06-25 21:50:15,199 CRIT Set uid to user 0
2019-06-25 21:50:15,199 WARN No file matches via include "/etc/supervisor/conf.d/*.conf"
2019-06-25 21:50:15,295 INFO RPC interface 'supervisor' initialized
2019-06-25 21:50:15,295 CRIT Server 'inet_http_server' running without any HTTP authentication checking
2019-06-25 21:50:15,457 INFO RPC interface 'supervisor' initialized
2019-06-25 21:50:15,457 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2019-06-25 21:50:15,457 INFO supervisord started with pid 1
2019-06-25 21:50:16,460 INFO spawned: 'php-fpm' with pid 10
2019-06-25 21:50:16,461 INFO spawned: 'laravel-worker_00' with pid 11
2019-06-25 21:50:16,463 INFO spawned: 'laravel-worker_01' with pid 12
2019-06-25 21:50:16,464 INFO spawned: 'laravel-worker_02' with pid 13
2019-06-25 21:50:16,467 INFO spawned: 'laravel-worker_03' with pid 14
2019-06-25 21:50:16,469 INFO spawned: 'laravel-worker_04' with pid 15
2019-06-25 21:50:16,472 INFO spawned: 'laravel-worker_05' with pid 16
2019-06-25 21:50:16,474 INFO spawned: 'laravel-worker_06' with pid 17
2019-06-25 21:50:16,476 INFO spawned: 'laravel-worker_07' with pid 18
2019-06-25 21:50:17,667 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-06-25 21:50:17,667 INFO success: laravel-worker_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-06-25 21:50:17,667 INFO success: laravel-worker_01 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-06-25 21:50:17,667 INFO success: laravel-worker_02 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-06-25 21:50:17,667 INFO success: laravel-worker_03 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-06-25 21:50:17,668 INFO success: laravel-worker_04 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-06-25 21:50:17,668 INFO success: laravel-worker_05 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-06-25 21:50:17,668 INFO success: laravel-worker_06 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-06-25 21:50:17,668 INFO success: laravel-worker_07 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-06-25 21:50:26,205 INFO exited: laravel-worker_00 (exit status 12; not expected)
2019-06-25 21:50:26,205 INFO exited: laravel-worker_02 (exit status 12; not expected)
2019-06-25 21:50:26,205 INFO exited: laravel-worker_03 (exit status 12; not expected)
2019-06-25 21:50:26,205 INFO exited: laravel-worker_05 (exit status 12; not expected)
2019-06-25 21:50:26,205 INFO exited: laravel-worker_06 (exit status 12; not expected)
2019-06-25 21:50:26,205 INFO exited: laravel-worker_07 (exit status 12; not expected)

最佳答案

您的工作人员正在退出,状态为 12:

2019-06-25 21:50:26,205 INFO exited: laravel-worker_00 (exit status 12; not expected)
2019-06-25 21:50:26,205 INFO exited: laravel-worker_02 (exit status 12; not expected)
2019-06-25 21:50:26,205 INFO exited: laravel-worker_03 (exit status 12; not expected)
2019-06-25 21:50:26,205 INFO exited: laravel-worker_05 (exit status 12; not expected)
2019-06-25 21:50:26,205 INFO exited: laravel-worker_06 (exit status 12; not expected)
2019-06-25 21:50:26,205 INFO exited: laravel-worker_07 (exit status 12; not expected)

当您的工作人员消耗过多内存时会触发此退出代码,请参阅: https://github.com/laravel/framework/blob/5.8/src/Illuminate/Queue/Worker.php#L204

$this->memoryExceeded($options->memory) 返回 true 并退出。

您有 2 个选择,减少 worker 的内存占用或增加允许的内存。由于默认值非常低 (128MB),您可以尝试添加一些内存。

要更改允许给您的工作人员的内存,您必须编辑您的主管配置:

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/artisan queue:work redis --sleep=3 --tries=3 --memory=1024
autostart=true
autorestart=true
user=www-data
numprocs=8
priority=10
redirect_stderr=true
stdout_logfile=/var/log/worker.log

请参阅我在命令部分添加到您的 conf 的 --memory

问候

关于laravel - docker : Worker keep exiting and respawn and 99% CPU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56762759/

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