-
-
Save eftakhairul/a6932e61d2e2e794736ef785d95b5ea2 to your computer and use it in GitHub Desktop.
Run a Go app with systemd
This file contains hidden or 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