kardianos / service

Run go programs as a service on major platforms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In Ubuntu 22.04 start error,but Ubuntu 20.04 start is ok

viseth opened this issue · comments

commented

Hi,

Installation as service on Ubuntu 20.04 works perfectly but failed to start on Ubuntu 22.04. There's a weird permission issue.
No SElinux enforced...

viz@viz-virtual-machine:~/Desktop/test/webserver$ sudo systemctl status TestWebserver.service
● TestWebserver.service - The Webserver is the component that manages the whole infrastructure and data. Components (a.k.a. Servers), Monitors, Reports, Downtimes, Users are managed throu>
Loaded: loaded (/etc/systemd/system/TestWebserver.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2023-06-19 19:00:14 CEST; 17s ago
Process: 3458 ExecStart=/home/viz/Desktop/test/webserver/webserver (code=exited, status=203/EXEC)
Main PID: 3458 (code=exited, status=203/EXEC)
CPU: 4ms

juin 19 19:00:14 viz-virtual-machine systemd[1]: TestWebserver.service: Main process exited, code=exited, status=203/EXEC
juin 19 19:00:14 viz-virtual-machine systemd[1]: TestWebserver.service: Failed with result 'exit-code'.
viz@viz-virtual-machine:~/Desktop/test/webserver$ sudo tail /var/log/syslog
Jun 19 18:59:42 viz-virtual-machine gnome-shell[1194]: DING: Detected async api for thumbnails
Jun 19 18:59:42 viz-virtual-machine gnome-shell[1194]: DING: GNOME nautilus 42.6
Jun 19 19:00:07 viz-virtual-machine systemd[1]: fprintd.service: Deactivated successfully.
Jun 19 19:00:14 viz-virtual-machine systemd[1]: TestWebserver.service: Scheduled restart job, restart counter is at 59.
Jun 19 19:00:14 viz-virtual-machine systemd[1]: Stopped The Webserver is the component that manages the whole infrastructure and data. Components (a.k.a. Servers), Monitors, Reports, Downtimes, Users are managed through the Webserver WebUI. It bundles its own API interface that starts up at the same time as its webUI..
Jun 19 19:00:14 viz-virtual-machine systemd[1]: Started The Webserver is the component that manages the whole infrastructure and data. Components (a.k.a. Servers), Monitors, Reports, Downtimes, Users are managed through the Webserver WebUI. It bundles its own API interface that starts up at the same time as its webUI..
Jun 19 19:00:14 viz-virtual-machine systemd[3458]: TestWebserver.service: Failed to execute /home/viz/Desktop/test/webserver/webserver: Permission denied
Jun 19 19:00:14 viz-virtual-machine systemd[3458]: TestWebserver.service: Failed at step EXEC spawning /home/viz/Desktop/test/webserver/webserver: Permission denied
Jun 19 19:00:14 viz-virtual-machine systemd[1]: TestWebserver.service: Main process exited, code=exited, status=203/EXEC
Jun 19 19:00:14 viz-virtual-machine systemd[1]: TestWebserver.service: Failed with result 'exit-code'.

ANy workaround ?
Thanks

From a quick google: https://serverfault.com/questions/957084/failed-at-step-exec-spawning-permission-denied

SELinux prevents you from running a system service where the binary is in a user's home directory [...]

To fix the problem, copy the binary to a proper directory such as /usr/local/bin and call it from there.