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/