Tuesday 28 May 2024

Running go binary as systemctl service

 https://sumitbopche01.medium.com/run-golang-executable-binary-as-daemon-service-ce306c740cca

https://askubuntu.com/questions/1063153/systemd-service-working-directory-not-change-the-directory


cd /etc/systemd/system/

vim yourservicename-service.service

[Unit]
Description=YourServiceName Service
After=syslog.target
[Service]
User=root
WorkingDirectory=/home/someuser
ExecStart=/bin/bash -c './somescript.sh args1 args2 args3'
Restart=always
[Install]
WantedBy=multi-user.target

-----------------------------------------------------

sudo systemctl enable yourservicename-service

sudo systemctl start yourservicename-service

sudo systemctl status yourservicename-service


No comments:

Post a Comment