我有一个用Django创建的Web服务器,但是在我创建我的sock文件之前,我的服务器已经关闭,nginx返回错误502,但是当我再次尝试时,我无法创建它。 / p>
pkill gunicorn
sudo systemctl daemon-reload
sudo systemctl start gunicorn
sudo systemctl enable gunicorn
我读了一些关于文件夹的Web权限但我认为包含我的服务器的文件夹具有所有可能的权限。
drwxrwxr-x 8 ubuntu ubuntu 4096 Sep 8 02:17 trackerServer
另一方面,这是我的/etc/systemd/system/gunicorn.service
文件:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/tracker-web/trackerServer
ExecStart=/home/ubuntu/tracker-web/trackerServer/env/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/tracker-web/trackerServer/trackerServer.sock trackerServer.wsgi:application
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/django_joya/
ExecStart=gunicorn --workers 3 --bind unix:/home/ubuntu/django_joya/joyas.sock joyas.wsgi:application
[Install]
WantedBy=multi-user.target
在服务器中有2个项目,但只有tracker-web/trackerServer
是我的,django_joya
是另一个人。
请帮助,我无法生成我的袜子文件
修改
当我尝试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 Fri 2017-09-08 03:00:20 UTC; 9h ago
Main PID: 11134 (code=exited, status=200/CHDIR)
Sep 08 03:00:20 ip-172-26-13-39 systemd[1]: Started gunicorn daemon.
Sep 08 03:00:20 ip-172-26-13-39 systemd[1]: gunicorn.service: Main process exited, code=exited, status=200/CHDIR
Sep 08 03:00:20 ip-172-26-13-39 systemd[1]: gunicorn.service: Unit entered failed state.
Sep 08 03:00:20 ip-172-26-13-39 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Sep 08 03:00:21 ip-172-26-13-39 systemd[1]: [/etc/systemd/system/gunicorn.service:15] Executable path is not absolute, ignoring: gunicorn --workers 3 --bind unix:/home/ubuntu/django
答案 0 :(得分:0)
日志显示的问题是执行var,你也有2个服务,删除一个。服务应如下所示:
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myproject
ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/sammy/myproject/myproject.sock myproject.wsgi:application
请记住更换gunicorn,sock和wsgi root。更多信息https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04#check-for-the-gunicorn-socket-file