Skip to content

Instantly share code, notes, and snippets.

@rockavoldy
Last active June 4, 2022 20:12
Show Gist options
  • Save rockavoldy/18cd96de06eea1d4b5d7b7447f748047 to your computer and use it in GitHub Desktop.
Save rockavoldy/18cd96de06eea1d4b5d7b7447f748047 to your computer and use it in GitHub Desktop.
Create systemd service to run Go apps

Create Systemd services to run Go apps

  1. Create new file with extension .service inside directory /lib/systemd/system/, in this example, i have rainsensor.service
  2. Copy below structure, and do some changes as you wish
[Unit]
Description=rainsensor

[Service]
Group=akhmad
Type=simple
Restart=always
RestartSec=5s
WorkingDirectory=/home/akhmad/rainsensor/
ExecStart=/home/akhmad/raindrop-server
PermissionsStartOnly=true
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=sleepservice

[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment