Now I was hoping to find a way to use systemd to tread the app as a service and start it when it is not running. Maybe it’s a bad idea to run it as a service and there might be a completely different way to achieve this. ?
But it still does not work.
Here my print out after calling sudo service myProg status
● myProg.service - my service
Loaded: loaded (/etc/systemd/system/myProg.service; disabled; vendor preset: enabled)
Active: failed (Result: signal) since Wed 2020-01-22 15:06:10 EST; 6s ago
Process: 1079 ExecStart=/usr/bin/sudo /home/pi/openFrameworks/apps/remotePulse/remotePulse/bin/remotePulse (code=k
Main PID: 1079 (code=killed, signal=SEGV)
Jan 22 15:06:10 raspberrypi systemd[1]: Started my service.
Jan 22 15:06:10 raspberrypi sudo[1079]: root : TTY=unknown ; PWD=/home/pi/openFrameworks/apps/remotePulse/remote
Jan 22 15:06:10 raspberrypi sudo[1079]: pam_unix(sudo:session): session opened for user root by (uid=0)
Jan 22 15:06:10 raspberrypi sudo[1079]: [ error ] ofAppGLFWWindow: 65544: X11: The DISPLAY environment variable is m
Jan 22 15:06:10 raspberrypi sudo[1079]: [ error ] ofAppGLFWWindow: couldn't init GLFW
Jan 22 15:06:10 raspberrypi sudo[1079]: [ error ] ofAppGLFWWindow: 65537: The GLFW library is not initialized
Jan 22 15:06:10 raspberrypi sudo[1079]: pam_unix(sudo:session): session closed for user root
Jan 22 15:06:10 raspberrypi systemd[1]: myProg.service: Main process exited, code=killed, status=11/SEGV
Jan 22 15:06:10 raspberrypi systemd[1]: myProg.service: Failed with result 'signal'.
You’ll probably be able to do it with Linux scripting, which I can’t help much with, but is ofxWatchdog (https://github.com/toolbits/ofxWatchdog) an option?
Hi,
I’ve recently used systemd to start some SuperCollider programs and had accidentally set Restart=always, which at least always restarted SC when I killed it with kill -9 PID.
Maybe you could try to start the app with systemd, instead of the autostart file?
I simply followed the Raspberry Pi instructions for systemd.
Oh, and is the [ error ] ofAppGLFWWindow: 65544: X11: The DISPLAY environment variable is missing a problem? In that case: that reminds me of starting GUI applications from SSH, to run on the remote machine.
Maybe you need to call
export DISPLAY=:0
xhost+
That’s at least what I do when I want to start OF-apps on my Ubuntu setup.
Now I think of it, I haven’t used that for my SC startup
Anyway, I called a .sh script from systemd, although I think putting everything in one line will do the job as well. ExecStart=sudo export DISPLAY=:1; xhost+; sudo /home/pi/openFrameworks/apps/remotePulse/remotePulse/bin/remoteP$
Not sure if this will work.
I had some problems with the unavailable X session (same kind of errors with the DISPLAY variable), which I didn’t need anyway, but SC needed it to start.
So I used a fake X server (Xvfb) to connect to (since I didn’t use a monitor)
But for your case:
I assume the Raspberry boots into autologin desktop mode? So then the X server should be available…
I think the service may be called too soon? This may work (setting the service to idle)?
Can’t test right now, so I apologize if my suggestions may lead to confusion.
But I will also add some more findings here for my future self.
I already have this watchdog.sh that I use on my macOS machines. It checks a log file and if this log file was not updated in the last n seconds it tries to start my OF app.
I modified it a bit and it now also runs a PI. But only if I call it through the terminal direclty. All of these 3 ways to call it work.
The trick was the Environment variables in the .service file (got them from here) I guess
It currently works with: sudo systemctl start startOF.service (launches the app)
Called sudo systemctl enable startOF.service and rebooted but haven’t got a monitor attached so that’s probably why the OF-app isn’t there when I log in with VNC-viewer.
(Edit: Restart=always isn’t implemented in my example, but for this thread it should)