I am trying to start Gunicorn from systemd service file, but I get import module error. How can I fix it?
My gunicorn service file:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myproject
ExecStart=/home/sammy/myproject/venv/bin/gunicorn --workers 3 --bind unix:/home/sammy/myproject/myproject.sock myproject.wsgi:application
[Install]
WantedBy=multi-user.target
When I execute gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application
, there is no error.
But when I use
sudo systemctl start gunicorn
sudo systemctl enable gunicorn
I get this error:
ImportError: No module named 'myproject'
What is wrong?
It is probably a directory permission problem. Make sure the user sammy is in the www-data group and set the home directory permissions with a chmod 710.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.