[Unit]
Description=Comm Test
ConditionPathExists=/usr/bin/commTest
After=network.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/usr/bin/commTest
ExecStart=/usr/lib/golang/bin run .
Restart=on-failure
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=commTest
[Install]
WantedBy=multi-user.target
I have disable the selinux via setenforce 0. Then when I run the status I get this error message.
Redirecting to /bin/systemctl status -l commTest.service
● commTest.service - Comm Test
Loaded: loaded (/etc/systemd/system/commTest.service; enabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since Tue 2023-01-03 20:48:06 +08; 7s ago
Process: 48515 ExecStart=/usr/lib/golang/bin run . (code=exited, status=203/EXEC)
Main PID: 48515 (code=exited, status=203/EXEC)
Jan 03 20:48:06 localhost.localdomain systemd[1]: commTest.service: main process exited, code=exited, status=203/EXEC
Jan 03 20:48:06 localhost.localdomain systemd[1]: Unit commTest.service entered failed state.
Jan 03 20:48:06 localhost.localdomain systemd[1]: commTest.service failed.
What I would like to find out is that besides this method is there any other method to run golang as daemon or this is the best method ?
I have managed to run it ready by changing this line ExecStart=/usr/lib/golang/bin run . to /usr/bin/commTest/commTest. But anyway is this the right method to daemonise or any other better method for golang ?
Hi Sibert,
Thank you yes I put my solution above after I found my mistake too. Few more questions I would like to confirm with you how about the User=root must it be root ? Also best how to maintain the logs. Lastly for golang will you recommend this method or any other method ?
I use Webmin to manage both VPS (Debian) and to view all logs.
Systemd is to me the standard way to start/restart/shutdown services.
Webmin have the possibility to create shortcuts for service management. And to easy manage several systemd tasks.