我使用 supervisord 来运行像 celery 这样的应用程序。
我使用nobody 用户来运行这些应用程序。但他们找不到环境变量。
例如,这是我使用nobody 用户的celery.conf。当我用 supervisord 运行 celery 时,它找不到我之前设置的 DJANGO_SETTINGS_MODULE 环境变量。
; ==================================
; celery worker supervisor
; ==================================
[program:celery]
command=/home/ubuntu/pl_env/bin/celery worker -A config --loglevel=INFO
directory=/home/ubuntu/petroline_django
user=nobody
numprocs=1
stdout_logfile=/var/log/celery/worker.log
stderr_logfile=/var/log/celery/worker.log
autostart=true
autorestart=true
startsecs=10
; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600
; Causes supervisor to send the termination signal (SIGTERM) to the whole process group.
stopasgroup=true
; Set Celery priority higher than default (999)
; so, if rabbitmq is supervised, it will start first.
priority=1000
最佳答案
我找到了environment
设置 supervisord configuration file , 可以用来解决这个问题。
关于ubuntu - 为 supervisord 没有人用户导出环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59504804/