How to configure systemd
Configure Systemd (systemctl)
Create a service file
For apps/services to Auto-start on boot/run automatically.
Gitea app/service used as an example
sudo nano /etc/systemd/system/gitea.servicePaste this content:
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
[Service]
Type=simple
User=gitea
Group=gitea
WorkingDirectory=/var/lib/gitea
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=gitea HOME=/var/lib/gitea GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.targetSave and exit (if nano: Ctrl+O, Enter, Ctrl+X).
Now enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable gitea
sudo systemctl start gitea
sudo systemctl status giteaThat's All!