Skip to content

Instantly share code, notes, and snippets.

@fabio-filho
Last active October 25, 2022 14:37
Show Gist options
  • Save fabio-filho/989c4f770cf95f9f40849ee715217694 to your computer and use it in GitHub Desktop.
Save fabio-filho/989c4f770cf95f9f40849ee715217694 to your computer and use it in GitHub Desktop.
linux - systemd - services

sudo vim /etc/systemd/system/my-server.service

/etc/systemd/system/my-server.service

[Unit]
Description=My Server
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
ExecStart=/usr/bin/python3 /home/ubuntu/my_server.py

User=ubuntu

Environment=ENV=production

Restart=always
RestartSec=1

[Install]
WantedBy=multi-user.target
sudo systemctl start my-server
sudo systemctl status my-server
sudo systemctl enable my-server

ref: https://antonputra.com/python/creating-a-linux-service-with-systemd/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment