I am trying to run a Golang server binary as a service with Systemd on Centos 8, but I get an error.
This is my script /etc/systemd/system/myserverapp.service
[Unit]
Description=MyServerApp
[Service]
Type=simple
ExecStart=/var/mybin/myserverapp
[Install]
WantedBy=multi-user.target
This is what I type:
sudo systemctl enable myserverapp
sudo systemctl start myserverapp
but it doesn't start, and if I type:
sudo systemctl status myserverapp
this is what I get:
● myserverapp.service - MyServerApp
Loaded: loaded (/etc/systemd/system/myserverapp.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2020-04-20 19:36:36 UTC; 2s ago
Process: 11228 ExecStart=/var/mybin/myserverapp (code=exited, status=203/EXEC)
Main PID: 11228 (code=exited, status=203/EXEC)
Apr 20 19:36:36 myserver systemd[1]: myserverapp.service: Main process exited, code=exited, status=203/EXEC
Apr 20 19:36:36 myserver systemd[1]: myserverapp.service: Failed with result 'exit-code'.
Apr 20 19:36:36 myserver systemd[1]: myserverapp.service: Service RestartSec=100ms expired, scheduling restart.
Apr 20 19:36:36 myserver systemd[1]: myserverapp.service: Scheduled restart job, restart counter is at 5.
Apr 20 19:36:36 myserver systemd[1]: Stopped MyServerApp.
Apr 20 19:36:36 myserver systemd[1]: myserverapp.service: Start request repeated too quickly.
Apr 20 19:36:36 myserver systemd[1]: myserverapp.service: Failed with result 'exit-code'.
Apr 20 19:36:36 myserver systemd[1]: Failed to start MyServerApp.
notice that if I run:
sudo /var/mybin/myserverapp
from the shell, the server binary runs correctly