前提・実現したいこと
django+Nginx+gunicornでEC2にデプロイを試した際、gunicornのステータスがfailedになります。原因が特定できません。有識者の皆様のお力をお借りしたく存じます。
【前提】
・プログラミング開発の業務経験はありません
・djangoをudemyで20時間ほど勉強したレベルです
【背景】
もともとdjangoで作成した簡単なブログアプリケーションをHEROKUにデプロイしていました。その際は正常にアプリケーションにアクセスができていました。ブログアプリケーションのインフラをAWSのEC2に発展させようと思い、インターネットで情報収集したところ、以下のリンク先のQiitaの記事が参考になりそうだと思い、環境変数等は自分の環境に置き換えて、実施してみました。
参考Qiita記事
発生している問題・エラーメッセージ
【ご質問内容】
この参考記事の中で、「Gunicornの設定」項目があり、以下のような作業をしているのですが、以下のようなステータス(Active: failed)になり、正常にGunicornを起動することができないでいます。エラー内容をインターネットで調査しているのですが、どの辺りに原因があるのか絞り込めないでいます。何か心当たりがあるかたがいらっしゃいましたら、アドバイス等いただけませんでしょうか
【Gunicornの作業内容】
sudo vim /etc/systemd/system/gunicorn.service ubuntu@ip-10-0-0-222:/etc/systemd/system$ more gunicorn.service [Unit] Description=gunicorn daemon After=network.target [Service] User=ubuntu Group=www-data WorkingDirectory=/home/ubuntu/myproject ExecStart=/home/ubuntu/python3/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/myproject/myproject.sock myproject.wsgi:application [Install] WantedBy=multi-user.target sudo systemctl start gunicorn.service sudo systemctl enable gunicorn```
【Gunicornのステータス】
ubuntu@ip-10-0-0-222:/etc/systemd/system$ sudo systemctl status gunicorn ● gunicorn.service - gunicorn daemon Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2021-03-15 13:12:23 UTC; 10min ago Process: 1888 ExecStart=/home/ubuntu/python3/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/myproject/myproject.sock myproject.wsgi:application (code=exited, status=1/FAILURE) Main PID: 1888 (code=exited, status=1/FAILURE) Mar 15 13:12:23 ip-10-0-0-222 gunicorn[1888]: self.stop() Mar 15 13:12:23 ip-10-0-0-222 gunicorn[1888]: File "/home/ubuntu/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 393, in stop Mar 15 13:12:23 ip-10-0-0-222 gunicorn[1888]: time.sleep(0.1) Mar 15 13:12:23 ip-10-0-0-222 gunicorn[1888]: File "/home/ubuntu/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld Mar 15 13:12:23 ip-10-0-0-222 gunicorn[1888]: self.reap_workers() Mar 15 13:12:23 ip-10-0-0-222 gunicorn[1888]: File "/home/ubuntu/python3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 525, in reap_workers Mar 15 13:12:23 ip-10-0-0-222 gunicorn[1888]: raise HaltServer(reason, self.WORKER_BOOT_ERROR) Mar 15 13:12:23 ip-10-0-0-222 gunicorn[1888]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3> Mar 15 13:12:23 ip-10-0-0-222 systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE Mar 15 13:12:23 ip-10-0-0-222 systemd[1]: gunicorn.service: Failed with result 'exit-code'. ubuntu@ip-10-0-0-222:/etc/systemd/system$
あなたの回答
tips
プレビュー