1

このチュートリアルを 2 回実行しましたが、実行した 2 番目のマシンでスーパーバイザー実行の gunicorn エラーが発生しました。スーパーバイザーに次のコマンドを使用して Gunicorn を起動するように指示すると、次のようになります。

$ sudo supervisorctl start gunicorn
gunicorn: ERROR (abnormal termination)

gunicorn_err.log はこれを繰り返します:

Unknown command: 'run_gunicorn'
Type 'manage.py help' for usage.

スーパーバイザーの構成は次のようになります。

[program:gunicorn]
command=/home/ubuntu/.virtualenvs/<VIRTUALENV>/bin/python /home/ubuntu/<APPNAME>/manage.py run_gunicorn -w 4 -k gevent
directory=/home/ubuntu/<APPNAME>
user=www-data
autostart=true
autorestart=true
stdout_logfile = /var/log/supervisor/gunicorn.log
stderr_logfile = /var/log/supervisor/gunicorn_err.log

gunicorn.log が空です。ユーザーをubuntuに変更し、virtualenvなしで実行しようとしました(すべての前提条件パッケージがあるため、「デフォルト」のpython環境も準備ができています。)gunicornの変数割り当て間のスペースを削除しようとしました。 conf 実際に手動で実行すると:

$ /usr/bin/python /home/ubuntu/<APPNAME>/manage.py run_gunicorn -w 4 -k gevent
2013-01-22 19:20:33 [1231] [INFO] Starting gunicorn 0.17.2
2013-01-22 19:20:33 [1231] [INFO] Listening at: http://127.0.0.1:8000 (1231)
2013-01-22 19:20:33 [1231] [INFO] Using worker: gevent
2013-01-22 19:20:33 [1236] [INFO] Booting worker with pid: 1236
2013-01-22 19:20:33 [1237] [INFO] Booting worker with pid: 1237
2013-01-22 19:20:33 [1238] [INFO] Booting worker with pid: 1238
2013-01-22 19:20:33 [1239] [INFO] Booting worker with pid: 1239

そして、virtualenv python の実行と同じ:

$ /home/ubuntu/.virtualenvs/<VIRTUALENV>/bin/python /home/ubuntu/<APPNAME>/manage.py run_gunicorn -w 4 -k gevent
2013-01-22 19:21:53 [1246] [INFO] Starting gunicorn 0.17.2
2013-01-22 19:21:53 [1246] [INFO] Listening at: http://127.0.0.1:8000 (1246)
2013-01-22 19:21:53 [1246] [INFO] Using worker: gevent
2013-01-22 19:21:53 [1251] [INFO] Booting worker with pid: 1251
2013-01-22 19:21:53 [1252] [INFO] Booting worker with pid: 1252
2013-01-22 19:21:53 [1253] [INFO] Booting worker with pid: 1253
2013-01-22 19:21:53 [1254] [INFO] Booting worker with pid: 1254

スーパーバイザーが開始した gunicorn が 'run_gunicorn' コマンドを見つけることができないのは、任意の python 環境を使用して実行でき、それが機能するのはどうしてですか? はい'gunicorn'INSTALLED_APPS

4

1 に答える 1

1

私が settings.py で取得していたのは、supervisord の start gunicorn の下には存在しなかった環境変数であることが判明しました。

さらに、環境変数のエラーが抑制されていて、gunicorn_err.log に記録されませんでした。

gunicorn.conf コマンドを次のように切り替えたとき:

command = /usr/local/bin/gunicorn_django -w 4 -k gevent

gunicorn_err.log でより明確なエラーを確認できました

    raise KeyError(key)
KeyError: 'AWS_STORAGE_BUCKET_NAME'
2013-01-22 22:51:09 [2290] [INFO] Worker exiting (pid: 2290)

これに対処するために、環境変数を使用せず、別の方法で変数を取得しました。それは機能し、元の virtualenv run_gunicorn コマンドに戻りました

command=/home/ubuntu/.virtualenvs/<VIRTUALENV>/bin/python /home/ubuntu/<APPNAME>/manage.py run_gunicorn -w 4 -k gevent

設定で環境変数を引き続き使用することが重要な場合は、supervisord-configurationを参照してください。supervisord が実行するアプリケーションのキーと値の環境変数のペアを設定する方法があるようです。

于 2013-01-22T19:05:47.883 に答える