# Auto-Start Web App

**URL:** <https://forum.xojo.com/t/auto-start-web-app/59749>\
**Category:** Raspberry Pi\
**Created:** [December 13, 2020, 1:36am UTC](https://forum.xojo.com/t/auto-start-web-app/59749 "2020-12-13T01:36:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julia\_Truchsess](https://forum.xojo.com/user_avatar/forum.xojo.com/julia_truchsess/32/499_2.png) [@Julia\_Truchsess](https://forum.xojo.com/u/Julia_Truchsess)\
**Post date:** [December 13, 2020, 1:36am UTC](https://forum.xojo.com/t/auto-start-web-app/59749/1 "2020-12-13T01:36:50Z")

</div>

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 😒):

> [@Running xojo executables on Raspberry Pi at boot](https://forum.xojo.com/t/running-xojo-executables-on-raspberry-pi-at-boot/40542/10):
>
> [quote=358069:@Grzegorz Pawlik]I have checked many methods found on the web, but none of them worked with Xojo GUI (Desktop) apps. That’s how I am doing it now (it works with Xojo GUI apps in the latest Raspbian Stretch): Go to /etc/xdg/autostart folder and create a new file there sudo nano /etc/xdg/autostart/myapp.desktop Type the following (changing the Name to your app name and Exec to the path to your app): [Desktop Entry] Type=Application Name=MyXojoApp Exec=sudo /path/to/your/xojo/GU…

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?

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [December 13, 2020, 1:51am UTC](https://forum.xojo.com/t/auto-start-web-app/59749/2 "2020-12-13T01:51:01Z")

</div>

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](https://strawberrysw.com/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.

---

<div class="post-metadata">

**Author:** ![Julia\_Truchsess](https://forum.xojo.com/user_avatar/forum.xojo.com/julia_truchsess/32/499_2.png) [@Julia\_Truchsess](https://forum.xojo.com/u/Julia_Truchsess)\
**Post date:** [December 14, 2020, 1:04am UTC](https://forum.xojo.com/t/auto-start-web-app/59749/3 "2020-12-14T01:04:26Z")

</div>

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

```
[Desktop Entry]
Type=Application
Name=<myxojoapp>
Exec=sudo /<pathtomyxojoapp>

```

Then type

`lxsession-edit`

into Terminal and make sure your app is checkmarked in the resulting GUI editor.

That’s it.

---

<div class="post-metadata">

**Author:** ![Jeannot\_Muller](https://forum.xojo.com/user_avatar/forum.xojo.com/jeannot_muller/32/13359_2.png) [@Jeannot\_Muller](https://forum.xojo.com/u/Jeannot_Muller)\
**Post date:** [December 14, 2020, 4:23pm UTC](https://forum.xojo.com/t/auto-start-web-app/59749/4 "2020-12-14T16:23:11Z")

</div>

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.
