Моя конфигурация systemd gunicorn3 выглядит так в /etc/systemd/system/gunicorn.service
[Unit]
Description=Gunicorn daemon for Django
Before=nginx.service
After=network.target
[Service]
WorkingDirectory=/home/django/betadmin/current
ExecStart=/usr/bin/gunicorn --name=betadmin --pythonpath=/home/django/betadmin/current --bind unix:/home/django/gunicorn.socket --config /etc/gunicorn.d/gunicorn.py betadmin.wsgi:application
Restart=always
SyslogIdentifier=gunicorn
User=django
Group=django
[Install]
WantedBy=multi-user.target
Моя инсталляция Django находится по адресу: /home/django/betadmin/current
Я добавил псевдонимы для pip3 и gunicorn3 в ~/.bash_aliases
alias python=python3
alias pip=pip3
alias gunicorn=gunicorn3
Моя конфигурация сайта nginx находится здесь: /etc/nginx/sites-enabled/django
upstream app_server {
server unix:/home/django/gunicorn.socket fail_timeout=0;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
client_max_body_size 4G;
server_name _;
keepalive_timeout 5;
# Your Django project's media files - amend as required
location /media {
alias /home/django/betadmin/current/betadmin/media;
}
# your Django project's static files - amend as required
location /static {
alias /home/django/betadmin/current/betadmin/static;
}
# Proxy the static assests for the Django Admin panel
location /static/admin {
alias /usr/lib/python3/dist-packages/django/contrib/admin/static/admin/;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://app_server;
}
}
Если я бегу
sudo service gunicorn status
● gunicorn.service - Gunicorn daemon for Django
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-11-07 15:27:18 UTC; 16min ago
Process: 2783 ExecStart=/usr/bin/gunicorn --name=betadmin --pythonpath=/home/django/betadmin/current --bind unix:/home/django/gunicorn.socket --config /etc/gunicorn.d/gunicorn.py betadmin.wsgi:application (code=exited, status=1/FAILURE)
Main PID: 2783 (code=exited, status=1/FAILURE)
Nov 07 15:27:18 django-admin-panel systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Nov 07 15:27:18 django-admin-panel systemd[1]: gunicorn.service: Service hold-off time over, scheduling restart.
Nov 07 15:27:18 django-admin-panel systemd[1]: gunicorn.service: Scheduled restart job, restart counter is at 5.
Nov 07 15:27:18 django-admin-panel systemd[1]: Stopped Gunicorn daemon for Django.
Nov 07 15:27:18 django-admin-panel systemd[1]: gunicorn.service: Start request repeated too quickly.
Nov 07 15:27:18 django-admin-panel systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Nov 07 15:27:18 django-admin-panel systemd[1]: Failed to start Gunicorn daemon for Django.
Я не уверен, в чем проблема? Кто-нибудь может подсказать? Я использую Ubuntu 18.04 и хочу запустить Django, используя python3.
Спасибо!