Skip to content

From Upstart to Systemd – Switch your Django Apps

Posted in Django, Server, and Ubuntu

In the beginning was Init. Then came Systemd. If you’re wondering how to switch your Django apps from Init to Systemd, here we go!

I build web apps, some of which might make your life easier. For instance, Custom MaterializeCSS Download allows you to customize MaterializeCSS in the browser before download.

Previously

With Django, you probably have something like this in your /etc/init/gunicorn.py file :

Then you followed that with independent configuration files for each of your Django project, like so:

Then you went ahead to map a proxy pass to the upstream server of the above gunicorn.conf of the respective project.

For the time, the process appears simple, but with Systemd, it becomes even simpler. You only need a service file for the Django project, then simply point to the sock file created by the Systemd process from your Nginx server block.

Now with SystemD

Your Nginx file might look like this (snippet taken from Django Hold It project):

A related Systemd service file responsible for creating the sock file will be like this:

Bring everything up nicely

Your server should be up and running like my LogECG and Django Hold It.

Thanks and hope to see you in the next one.