9

セロリ機能を備えたdjangoアプリがあるので、以下のようにセロリを正常に実行できます

celery -A tasks worker --loglevel=info

しかし、デーモンとして実行する必要があるという既知の事実として、フォルダーcelery.conf内に以下のファイルを書きました/etc/supervisor/conf.d/

; ==================================
;  celery worker supervisor example
; ==================================

[program:celery]
; Set full path to celery program if using virtualenv
command=/root/Envs/proj/bin/celery -A app.tasks worker --loglevel=info

user=root
environment=C_FORCE_ROOT="yes"
environment=HOME="/root",USER="root"
directory=/root/apps/proj/structure
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

; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true

; if rabbitmq is supervised, set its priority higher
; so it starts first
priority=998

しかし、スーパーバイザーを次のように更新しようとすると、supervisorctl rereadからsupervisorctl updateメッセージが表示されましたsupervisorctl status

celery                           FATAL      Exited too quickly (process log may have details)

だから私はworker.logファイルに行き、以下のようなエラーメッセージを見ました

Running a worker with superuser privileges when the
worker accepts messages serialized with pickle is a very bad idea!

If you really want to continue then you have to set the C_FORCE_ROOT
environment variable (but please think about this before you do).

User information: uid=0 euid=0 gid=0 egid=0

C_FORCE_ROOTでは、スーパーバイザーの conf ファイル内で環境変数として設定したにもかかわらず、なぜ文句を言って いるのでしょうか? 上記のconfファイルで何が間違っていますか?

4

3 に答える 3

2

スーパーユーザー以外のアカウントでセロリを実行する必要があります。設定から次の行を削除してください。

user=root
environment=C_FORCE_ROOT="yes"
environment=HOME="/root",USER="root"

djangoそして、これらの行を構成に追加します。非スーパーユーザーおよびdevelopersユーザーグループとして使用すると仮定します。

user=django
group=developers

サブプロセスは、ここで上書きされたものとプログラムの環境オプション内のものを除いて、supervisord の起動に使用されるシェルの環境変数を継承することに注意してください。監督文書を参照してください。

supervisorそのため、構成ファイルを介して環境変数を変更すると、実行しても変更が適用されないことに注意してください。次のコマンドを使用して、最初からスーパーバイザーを実行する必要があります。supervisorctl rereadsupervisorctl reload

supervisord -c /path/to/config/file.conf
于 2015-11-22T12:32:51.253 に答える