Skip to content

Instantly share code, notes, and snippets.

@SumonMSelim
Created October 21, 2021 16:45
Show Gist options
  • Save SumonMSelim/ecd60123f44fbebc07616dcfe9dffae8 to your computer and use it in GitHub Desktop.
Save SumonMSelim/ecd60123f44fbebc07616dcfe9dffae8 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