1

I followed this guide to setup Django with Gunicorn, but ran into a problem where Ubuntu 15.10 uses systemd instead of upstart. So after asking a question here to figure that out, I found another guide for CentOS to help me configure systemd.

With that in mind, I came up with the following gunicorn.service file:

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=root
Group=root
WorkingDirectory=/home/webapps/games
ExecStart=/home/webapps/games/venv/bin/gunicorn --workers 3 --bind unix:/home/webapps/games/games.sock games.wsgi:application

[Install]
WantedBy=multi-user.target

I set the group/user to root just to make sure permissions are causing problems temporarily. The directory structure is as follows at /home/webapps/games

├── games
│   └── wsgi.py
├── venv
│   └── bin
│       └── gunicorn
└── manage.py 

When I try to run service gunicorn start I get a cryptic error gunicorn: unrecognized service. I'm not sure where to go from here and I can't find any logs either. Any ideas?

When running this from the command line gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application it works as expected and serves files.

1 Answer 1

0

If you are on ubuntu then it I don't think that CentOS instructions will work. Taken from DigitalOcean tutorial you should create .conf file for upstart:

description "Gunicorn application server handling myproject"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
setude user
setgid www-data
chdir /home/webapps

exec /home/webapps/games/venv/bin/gunicorn --workers 3 --bind unix:/home/webapps/games/games.sock games.wsgi:application

Notes

  1. user should be user owning the environment and the project and for group his group.
  2. File should live in /etc/init/gunicorn.conf.
  3. Log files for upstart gunicorn would be in /var/log/upstart/gunicorn.conf

you

2
  • Thank you for this, but the problem is that upstart has been removed with Ubuntu 15.10, and that is why I had to move to default systemd and the CentOS configuration. However, I can't imagine the configuration being that different for a specific application, but maybe an expert can chime in.
    – clueless
    Mar 24, 2016 at 17:16
  • sudo apt-get install upstart also in your links for centOS sudo systemctl start unicorn is used not service Mar 25, 2016 at 9:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .