Sanic application as a service in Ubuntu/Linux

Hi everyone,

I have followed a couple of recipes for setting up my Sanic application as a service on an Ubuntu 19.10 server:
https://tecadmin.net/setup-autorun-python-script-using-systemd/
https://www.digitalocean.com/community/questions/trying-to-change-workingdirectory-of-systemd-service-unit

I created the service file:
sudo vi /lib/systemd/system/dummy.service

I then enabled/start/status the server:

sudo systemctl daemon-reload
sudo systemctl enable dummy.service
sudo systemctl start dummy.service
sudo systemctl status dummy.service

And got errors:

The service should be available at:
http://x.y.z.w:9000/

Can anyone point me out as to what is needed to get this up and working? Usinf Python 3.8 and latest Poetry virtual environment to get it up and running (it does work when launching it via the terminal and setting it up in the background).

Thank you again!

What is logged in journalctl for the failure?

@sjsadowski Here are the logs:

Looks like the problem is within poetry itself, for now - however it seems to be that poetry is implying that it’s using python 2.7 so maybe that’s an issue?

1 Like

There are complete instructions (without poetry/venv though) at sanic/blob/master/docs/sanic/nginx.rst

P.S. Could someone merge the last open doc PR https://github.com/huge-success/sanic/pull/1805 and then update https://sanic.readthedocs.io/en/latest/ thanks.

1 Like