Having great success compiling and running WebApps on Linux RPi. However, I want to Daemonize the app to run after terminal closes - and the “Call Daemonize” function (App.Open) won’t compile. I get the following error: “This item does not exist”
Looking for advice - appreciate your help!
I’ve updated that doc page.
Hi Paul, I tried and still get a compile error (xojo ver. 2015 rev. 3.1).
"Type “App” has no member named “Daemonize”.
Re-reading your first post, you mention you are using App.Open. That would imply this is not a Console app. The App.Daemonize method is only available in Console apps, so you would call it in the App.Run event handler.
And re-reading again (I should probably go to bed at this point), I see you might be doing a web app, which does have an App.Open event. This should work fine with App.Daemonize and in my quick test it I don’t get a compile error.
So in closing: it doesn’t work in a desktop app.
Trying to Daemonize a Linux Web App, if you look at the link (below), it seems to imply you can Daemonize a Linux stand-alone web app:
…and here’s an excerpt from this page… (BTW: I appreciate your help!)
Note that if you exit from ssh your web app will terminate unless you daemonize it. Use this code in the App.Open event to daemonize a standalone web application:
Don’t call App.Daemonize. This is already done for you in the initialization of a standalone web app.
Hi Greg, I appreciate your insight. The Dev docs (online) lead me to believe otherwise. I suppose I can look for a Linux (OS) script that will allow me to launch the app (as I do in Terminal via “./MyAppName”), and keep it running 24/7. This may be a non-issue after all, but then again I haven’t tried the scripted approach yet My ideal world is to have it launch on startup, no human intervention, and then be re-launched should the app choke at any point.
Calling app.daemonize doesn’t mean that the app will be kept running. It separates the process from the user that launched it so that user can log out without terminating the process. If you want your app to stay running, you’ll need to create a service on your Linux box to do that for you.
I want to do both, and was hoping to start with item #1: daemonize so user session could be logged out and leave app running. Is there a way to do this?
I haven’t had a use for this in a while, but putting an & at the end of the command might do the trick. You might need a little more work to go with it depending on what you are doing exactly. Here’s a link for you.
Kevin, nice tip! I ended up running this launch string in SSH Terminal…
pi@raspberrypi ~/Desktop/MyApp $ sudo ./MyApp --port=80 &
…and it does in fact free up the session and allow me to exit out. I suppose I should do a bunch of research to see what the pros/cons are of using this (name unknown to me) ampersand trick. Thanks for the lead!
My mistake. App.Daemonize is called for CGI apps, not for Standalone apps.
One last question before I check the answered-box… Should ‘daemonize’ be added to a Standalone app, or should it be handled via the Linux host OS’s run methods?
I don’t think I’ve ever added daemonize to standalone apps I’ve deployed. I normally just set up a script in the style of the OS I’m deploying on to make sure the webapp loads at bootup. On OS X I use a launchd plist file. On linux it varies based on platform, but it shouldn’t be hard to find what to use with some googling. On ubuntu it would be an init or systemd script depending on which version of Ubuntu you use. HTH.
All of this was helpful. Have a great week, and thanks for all your time!