gunicorn.service无法打开WorkingDirectory和gunicorn可执行文件。我认为这是有关权限的问题,但我不知道如何解决。
sudo systemctl status gunicorn:
Mar 15 12:12:42 ns1.localhost.com systemd[1]: Started gunicorn daemon.
Mar 15 12:12:42 ns1.localhost.com systemd[16439]: gunicorn.service: Changing to the requested working directory failed: No such file or directory
Mar 15 12:12:42 ns1.localhost.com systemd[16439]: gunicorn.service: Failed at step CHDIR spawning /home/radarkes-api/env/bin/gunicorn: No such file or directory
Mar 15 12:12:42 ns1.localhost.com systemd[1]: gunicorn.service: Main process exited, code=exited, status=200/CHDIR
Mar 15 12:12:42 ns1.localhost.com systemd[1]: gunicorn.service: Failed with result 'exit-code'.
/etc/systemd/system/gunicorn.service:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/home/radarkes-api/src
ExecStart=/home/radarkes-api/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/radarkes-api/src/core.sock core.wsgi:application
[Install]
WantedBy=multi-user.target
我可以手动运行/home/radarkes-api/env/bin/gunicorn,以下是输出结果,这意味着我可以访问gunicorn可执行文件:
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: No application module specified.
我尝试了:
- 在ExecStart的开头添加“source /home/radarkes-api/env/bin/activate &&”。
- chmod -R 777 /home/radarkes-api
tree -d -L 2 /home/radarkes-api/:
radarkes-api/
├── env
│ ├── bin
│ └── lib
└── src
├── api
└── core
我该怎样解决这个问题?