Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6037

Troubleshooting • Re: Trouble Creating A Systemd Service

$
0
0
The ExecStart doesn't start a shell and it doesn't support globbing (i.e. *.go). The best way to do this would be to create a shell script

Code:

sudo tee /usr/local/bin/webrtc.sh#!/usr/bin/bashGO111MODULE=on/usr/bin/go run *.goEOFsudo chmod +x /usr/local/bin/webrtc.sh
and change your service to this ...

Code:

sudo tee /etc/systemd/system/webrtc.service >/dev/null << EOF[Unit]Wants=network.target[Service]ExecStart=/usr/local/bin/webrtc.shWorkingDirectory=/home/nickserver/RTSPtoWebRTC[Install]WantedBy=multi-user.targetEOF

When I do this, I get this output:

Code:

× webrtc.service     Loaded: loaded (/etc/systemd/system/webrtc.service; enabled; preset: enabled)     Active: failed (Result: exit-code) since Sun 2024-01-28 14:45:41 ACDT; 6s ago   Duration: 12ms    Process: 14302 ExecStart=/usr/local/bin/webrtc.sh (code=exited, status=127)   Main PID: 14302 (code=exited, status=127)        CPU: 14mssystemd[1]: Started webrtc.service.webrtc.sh[14305]: go: module cache not found: neither GOMODCACHE nor GOPATH is setwebrtc.sh[14312]: /usr/local/bin/webrtc.sh: line 4: EOF: command not foundsystemd[1]: webrtc.service: Main process exited, code=exited, status=127/n/asystemd[1]: webrtc.service: Failed with result 'exit-code'.
journalctl -f -u webrtc.service provided me:

Code:

systemd[1]: webrtc.service: Failed with result 'exit-code'.systemd[1]: Started webrtc.service - Start RTSPtoWebRTC.webrtc.sh[10583]: go: module cache not found: neither GOMODCACHE nor GOPATH is setsystemd[1]: webrtc.service: Main process exited, code=exited, status=1/FAILUREsystemd[1]: webrtc.service: Failed with result 'exit-code'.systemd[1]: Started webrtc.service.webrtc.sh[14305]: go: module cache not found: neither GOMODCACHE nor GOPATH is setwebrtc.sh[14312]: /usr/local/bin/webrtc.sh: line 4: EOF: command not foundsystemd[1]: webrtc.service: Main process exited, code=exited, status=127/n/asystemd[1]: webrtc.service: Failed with result 'exit-code'.
I tried running the shell script by itself and I got this error:

Code:

stat *.go: no such file or directory./webrtc.sh: line 4: EOF: command not found
So I removed the "EOF" from the bash script and I get:

Code:

stat *.go: no such file or directory
After some trial and error, I managed to get the bash script to execute and work the way I want with:

Code:

#!/usr/bin/bashGO111MODULE=oncd /home/nickserver/RTSPtoWebRTCgo run *.go
However the webrtc.service still does not execute the shell script (as errors above).

Thanks for your help!

Statistics: Posted by Yahoo Kazooie — Sun Jan 28, 2024 4:25 am



Viewing all articles
Browse latest Browse all 6037

Trending Articles