Created
October 21, 2021 16:45
-
-
Save SumonMSelim/ecd60123f44fbebc07616dcfe9dffae8 to your computer and use it in GitHub Desktop.
Run a Go app with systemd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /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