我在 Tornado 服务器上使用 Supervisord 和 Celery(注意:不是 tcelery,因为我的服务器还没有使用任何异步功能)和三个工作人员:w1、w2 和 w3。每个都有 10 的并发数。我通过主管通过将以下内容添加到 /etc/supervisord.conf 来执行此操作:
[program:sendgrid_gateway_server]
command=sudo python main.py -o runserver
numprocs=1
directory=/home/ubuntu/sendgrid_gateway/sendgrid-gateway
stdout_logfile=/home/ubuntu/sendgrid_gateway/sendgrid-gateway/logs/server_log.txt
autostart=true
autorestart=true
user=root
[program:sendgrid_gateway_server_w1]
command=celery worker -A tasks --loglevel=INFO --concurrency=10 -n w1
numprocs=1
directory=/home/ubuntu/sendgrid_gateway/sendgrid-gateway
stdout_logfile=/home/ubuntu/sendgrid_gateway/sendgrid-gateway/logs/w1_log.txt
autostart=true
autorestart=true
user=root
[program:sendgrid_gateway_server_w2]
command=celery worker -A tasks --loglevel=INFO --concurrency=10 -n w2
numprocs=1
directory=/home/ubuntu/sendgrid_gateway/sendgrid-gateway
stdout_logfile=/home/ubuntu/sendgrid_gateway/sendgrid-gateway/logs/w2_log.txt
autostart=true
autorestart=true
user=root
[program:sendgrid_gateway_server_w3]
command=celery worker -A tasks --loglevel=INFO --concurrency=10 -n w3
numprocs=1
directory=/home/ubuntu/sendgrid_gateway/sendgrid-gateway
stdout_logfile=/home/ubuntu/sendgrid_gateway/sendgrid-gateway/logs/w3_log.txt
autostart=true
第一个 [program] 块用于运行 Tornado 的主要 python 应用程序。接下来的三个(显然)是我的芹菜工人。让我担心的是,当我“supervisorctl start all”时,所有 30 个进程都会出现在列表中:
根 2547 0.0 0.0 40848 1672 ?S 13:40 0:00 sudo python main.py -o runserver root 2548 0.2 1.9 176140 33020 ?Sl 13:40 0:04 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w3 root 2549 0.0 2.1 196848 35632 ?S 13:40 0:01 python main.py -o runserver root 2560 0.2 1.9 176140 33016 ?Sl 13:40 0:03 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w2 root 2561 0.2 1.9 176140 33020 ?Sl 13:40 0:03 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w1 root 2581 0.0 1.6 175144 28616 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w3 root 2582 0.0 1. 6 175144 28624 ? S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w3 root 2583 0.0 1.6 175144 28628 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w3 root 2584 0.0 1.6 175144 28628 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A 任务 --loglevel=INFO --concurrency=10 -n w3 root 2585 0.0 1.6 175144 28628 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w3 root 2586 0.0 1.6 175144 28632 ? S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w3 root 2587 0.0 1.6 175144 28632 ? 13:40 0: 00 /usr/bin/python /usr/local/bin/celery worker -A 任务 --loglevel=INFO --concurrency=10 -n w3 root 2589 0.0 1.6 175144 28636 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w3 root 2590 0.0 1.6 175144 28644 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w3 root 2591 0.0 1.6 175144 28640 ? S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w3 root 2595 0.0 1.6 175144 28612 ? S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w2 root 2596 0.0 1.6 175144 28624 ?13:40 0: 00 /usr/bin/python /usr/local/bin/celery worker -A 任务 --loglevel=INFO --concurrency=10 -n w1 root 2597 0.0 1.6 175144 28632 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w1 root 2598 0.0 1.6 175144 28620 ? S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w2 root 2599 0.0 1.6 175144 28620 ? S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w2 root 2600 0.0 1.6 175144 28620 ? S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w2 root 2601 0.0 1.6 175144 28624 ?13:40 0: 00 /usr/bin/python /usr/local/bin/celery worker -A 任务 --loglevel=INFO --concurrency=10 -n w2 root 2602 0.0 1.6 175144 28636 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w1 root 2603 0.0 1.6 175144 28628 ? S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w2 root 2604 0.0 1.6 175144 28636 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w1 root 2605 0.0 1.6 175144 28632 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w1 root 2608 0.0 1.6 175144 28632 ?13:40 0: 00 /usr/bin/python /usr/local/bin/celery worker -A 任务 --loglevel=INFO --concurrency=10 -n w1 root 2609 0.0 1.6 175144 28628 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w2 root 2610 0.0 1.6 175144 28640 ? S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w1 root 2611 0.0 1.6 175144 28640 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w1 root 2612 0.0 1.6 175144 28632 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w2 root 2613 0.0 1.6 175144 28648 ?13:40 0: 00 /usr/bin/python /usr/local/bin/celery worker -A 任务 --loglevel=INFO --concurrency=10 -n w1 root 2614 0.0 1.6 175144 28644 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w1 root 2616 0.0 1.6 175144 28640 ? S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A tasks --loglevel=INFO --concurrency=10 -n w2 root 2617 0.0 1.6 175144 28636 ? S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A 任务 --loglevel=INFO --concurrency=10 -n w2 00 /usr/bin/python /usr/local/bin/celery worker -A 任务 --loglevel=INFO --concurrency=10 -n w2 root 2617 0.0 1.6 175144 28636 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A 任务 --loglevel=INFO --concurrency=10 -n w2 00 /usr/bin/python /usr/local/bin/celery worker -A 任务 --loglevel=INFO --concurrency=10 -n w2 root 2617 0.0 1.6 175144 28636 ?S 13:40 0:00 /usr/bin/python /usr/local/bin/celery worker -A 任务 --loglevel=INFO --concurrency=10 -n w2
这些是 30 个 Celery 进程,加上一些额外的进程(不太清楚为什么会有额外的进程......)我的印象是,不必要的进程应该在任务完成后终止。是这种情况还是我只是个疯子?
提前致谢。