For some years now (how time flies!) I’ve been running a web app on a Raspberry Pi. It’s been rock-solid, restarting itself after power outages. I recently decided to try using the same Pi as a Time Machine server. The Time Machine directions started off by saying “make sure your Pi is running the latest version of Buster”, so I found and followed some step-by-step directions for upgrading Stretch to Buster, which naturally resulted in a bricked Pi . So now starting from scratch with a fresh Buster install, my Xojo web app launches fine but does not auto-restart, despite its being “daemonized”. I have not touched the built Xojo app, just copied it over.
The Xojo docs rather tersely state that “if you exit from ssh your web app will terminate unless you daemonize it”, but there is no mention of auto-restarting. I understand Xojo’s adamant stand against offering specific configuration advice, but surely anyone running a web server wants it to restart after a power outage, no?
To my surprise, I found that I’d actually commented on this thread (which I can’t add to because of the misguided (imo) forum policy of closing threads, so now there are two threads on the same topic ):
saying that I’d found a solution, but I don’t know if that pre-dates my notes to myself saying that all I need to do is daemonize the app. I have a vague recollection about needing to “run it as a service” or something like that.
Can anyone clarify the role of daemonization and what is the best/recommended practice for ensuring auto-restart?
Daemonization is what sends your app to the background so you can exit the ssh session without terminating the app. There are other ways to achieve a similar effect.
My preferred method is with system services. This is how my web deployment tool Lifeboat configures a server to run apps. With the flavors I support, there is a service manager called systemd and that’s what re-launches an app after it crashes or the server reboots.
Searching quickly it appears Buster is Debian based, so you should also have systemd. Debian support is on my list of things to add to Lifeboat. I’ve got a few other things to catch up on first though.
I got it working, using the autostart folder and lxsession editor, which was pretty straightforward once I realized that the line breaks in @Grzegorz_Pawlik’s original post had gotten messed up in the forum transition.
First create a file myxojoapp.desktop in /etc/xdg/autostart. The extension must be “.desktop”.
Edit the file myxojoapp.desktop in /etc/xdg/autostart to contain these lines
Great, if you have some time one day to dive a bit into linux system services as suggested by @Tim_Parnell you will love it: Biggest advantage: rightly configured it will restart your app not only upon booting but as well if it might crash. That’s quite convenient.