#Running gunicorn.service with Django app

5 messages · Page 1 of 1 (latest)

late hazel
#

I'm trying to deploy my Django app on DigitalOcean (i've been following the "How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu" tutorial) but I'm stuck on running gunicorn.service. I'm able to start and enable it fine with systemctl, but when I try running "curl --unix-socket /run/gunicorn.sock localhost" it keeps returning errors. My service file looks like this:

Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=root
Group=www-data
WorkingDirectory=/root/myprojectdir
ExecStart=/root/myprojectdir/myprojectenv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          myapp.wsgi:application

[Install]
WantedBy=multi-user.target```

In journalctl, initially it just gave "gunicorn.service: Failed with result 'exit-code'." but after trying some bug fixes, it looks like it is able to start but gives a ModuleNotFoundError for my app name.
late hazel
#

Never mind, I am dumb and did not have WorkingDirectory set to the actual directory of my app.

proper parcel
#
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=root
Group=www-data
WorkingDirectory=/root/myprojectdir
ExecStart=/root/myprojectdir/myprojectenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock myapp.wsgi:application

[Install]
WantedBy=multi-user.target```
#

@late hazel here you go )

#

actually you have to remove that \ and erase unnecessary spaces