Persisting Go using systemd - zelenko/go GitHub Wiki
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.servicesystemctl start golang.servicesystemctl status golang.servicesystemctl stop golang.service
Find the version of systemd
dpkg -l systemdwill give you name, version, and architecture description.systemctl --versionPrint a short version string