簡體   English   中英

使用Gunicorn部署Django應用程序時出錯?

[英]Error while deploying Django application with Gunicorn?

我試圖像下面這樣使用ngnix-gunicorn部署django應用程序: https ://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on- ubuntu-16-04我沒有使用virtualenv。 這是'gunicorn.service'文件。 當我嘗試制作一個systemd時,我遇到了一個錯誤。

[Unit]
Description=gunicorn daemon
After=network.target
[Service]
Environment=SECRET_KEY='*uj$'
User=root
Group=www-data
WorkingDirectory=/root/myproject
ExecStart=/usr/local/bin/gunicorn --access-logfile - --workers 3 --bind unix:/root/myproject/myproject.sock myproject.wsgi:application

[Install]
WantedBy=multi-user.target

這是創建systemd時的錯誤。

● gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2017-08-26 14:05:19 UTC; 6s ago
  Process: 24747 ExecStart=/usr/local/bin/gunicorn --access-logfile - --workers 3 --bind unix:/root/test1/test1.sock test1.wsgi:applica
 Main PID: 24747 (code=exited, status=200/CHDIR)

Aug 26 14:05:19 ip-172-31-1-229 systemd[1]: Started gunicorn daemon.
Aug 26 14:05:19 ip-172-31-1-229 systemd[1]: gunicorn.service: Main process exited, code=exited, status=200/CHDIR
Aug 26 14:05:19 ip-172-31-1-229 systemd[1]: gunicorn.service: Unit entered failed state.
Aug 26 14:05:19 ip-172-31-1-229 systemd[1]: gunicorn.service: Failed with result 'exit-code'.

我試着在主管的監督下經營金槍魚。 使用以下配置,它的工作效果非常好。

[program:analytics]
command = /home/ubuntu/code/analytics/bin/gunicorn example.wsgi:application --name example --workers 4 --user=ubuntu --timeout=3600 --bind 127.0.0.1:8000
user = ubuntu ; User to run as
stdout_logfile = /home/ubuntu/code/example/current/slog/gunicorn_start.log  ; Where to write log messages
redirect_stderr = true     ; Save stderr in the same log
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8,PYTHONPATH=/home/ubuntu/code/current/example/bin/python ; Set UTF-8 as default encoding

您可以嘗試將supervisord作為pip安裝,並使用supervisord.conf的include參數將上述配置包含在其中。

有關更多信息: http : //supervisord.org/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM