我正在尝试在gunicorn套接字上运行django项目作为服务。但是它无法启动;有人可以帮我吗?
我尝试通过以下链接进行操作:https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04 我也在使用virtualenvwrapper来管理我的virtualenvs。
这是我的配置文件: /etc/systemd/system/gunicorn.socket:
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
/etc/systemd/system/gunicorn.service:
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=mohsen
Group=www-data
WorkingDirectory=/home/mohsen/Desktop/SummerCampDocs/carpooling/carpooling
ExecStart=/home/mohsen/.virtualenvs/carpooling/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock carpooling.wsgi:application
[Install]
WantedBy=multi-user.target
通过运行以下命令:
sudo systemctl start gunicorn.socket
sudo systemctl enable gunicorn.socket
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 Wed 2019-08-28 12:38:18 +0430; 33min ago
Process: 14000 ExecStart=/home/mohsen/.virtualenvs/carpooling/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock carpooling.wsgi:application (code=exited, status=1/FAILURE)
Main PID: 14000 (code=exited, status=1/FAILURE)
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: self.stop()
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: File "/home/mohsen/.virtualenvs/carpooling/lib/python3.6/site-packages/gunicorn/arbiter.py", line 393, in stop
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: time.sleep(0.1)
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: File "/home/mohsen/.virtualenvs/carpooling/lib/python3.6/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: self.reap_workers()
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: File "/home/mohsen/.virtualenvs/carpooling/lib/python3.6/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
Aug 28 12:38:18 mohsen-ThinkPad-T490 gunicorn[14000]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
Aug 28 12:38:18 mohsen-ThinkPad-T490 systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Aug 28 12:38:18 mohsen-ThinkPad-T490 systemd[1]: gunicorn.service: Failed with result 'exit-code'.