Run Golang Executable binary as Daemon Service
Dec 28, 2021
Change directory
cd /etc/systemd/system/
Create a configuration for your project
vim yourservicename-service.service
Paste the following, change the binary path, and save
[Unit]Description=YourServiceName ServiceAfter=syslog.target[Service]User=rootWorkingDirectory=/apps/yourServiceName-serviceExecStart=/apps/yourServiceName-service/yourservicename-serviceRestart=always[Install]WantedBy=multi-user.target
Start the service
sudo systemctl start yourservicename-service
Check status
sudo systemctl status yourservicename-service