Skip to content

Persisting Go using systemd

Zelenko edited this page Mar 25, 2018 · 2 revisions

Persisting

Start your go app when the server starts. In other word daemonize your golang program.

Systemd

cd /etc/systemd/system/

nano golang.service

[Unit]
Description=Go Server

[Service]
ExecStart=/var/www/web
WorkingDirectory=/var/www/
User=root
Group=root
Restart=always

[Install]
WantedBy=multi-user.target

Start the service

  • systemctl enable golang.service
  • systemctl start golang.service
  • systemctl status golang.service
  • systemctl stop golang.service
Clone this wiki locally