Skip to content

Instantly share code, notes, and snippets.

@eftakhairul
Forked from SumonMSelim/systemd.README
Created January 18, 2026 03:24
Show Gist options
  • Select an option

  • Save eftakhairul/a6932e61d2e2e794736ef785d95b5ea2 to your computer and use it in GitHub Desktop.

Select an option

Save eftakhairul/a6932e61d2e2e794736ef785d95b5ea2 to your computer and use it in GitHub Desktop.
Run a Go app with systemd
# /etc/systemd/system/url-shortener.service
```
[Unit]
Description=url-shortener
Wants=network.target
After=network.target
[Service]
Type=simple
Restart=always
RestartSec=5
WorkingDirectory=/home/deploy/goapp
ExecStart=/home/deploy/goapp/url-shortener serve
[Install]
WantedBy=multi-user.target
```
# To enable it on boot
sudo systemctl enable url-shortener
# Start the service
sudo systemctl start url-shortener
# Status of the service
sudo systemctl status url-shortener
# Restart the service
sudo systemctl restart url-shortener
# Reload after configuration change
sudo systemctl daemon-reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment