I have this happen all the time, basically everytime I update my console app, or web app that runs on a Pi… The app will start, then quit by itself. The error logs show nothing, the Linux Sys log(s) show only the startup and the log entries I have coded into the app - but nothing with regard to why the app would spontaneously quit!
Tonite, I updated the SQLite database, and added Xojoversionstring to the app so it would write it to the database on start, and then could be read by a web app page.
Can anyone tell me some clues to solve why this is happening and what to do about it?
In some cases, it has been Xojo version - I have better luck with 2017R3 than any of the 2018 versions. But again, it is different from app to app. ie some apps compiled in 2018Rx are fine, some are not. Some must be done in 2017R3. Sometimes it is helpful to shut down the Pi, sometimes it does not matter (just stop the app, upload new and restart the app). Very very strange!
Anyway, this is an enormous problem since it take hours to get it figured out, and there is never a ryhm or reason as to why it finally works! Not good for something that should be production ready!
If its a standalone web app, check to make sure the previous version has been terminated. If a web app cannot listen on the port you requested, it will immediately quit.
Hi Greg,
I always kill the apps before uploading a replacement.
In the scenario you outined, does the framework write to any system log or provide any indication whatsoever of the cause of the shutdown?
In my case, the standalone web app is not the problem, but other console apps are! Is there any way to find out why they are starting then shutting down?
I Ivan.
The apps eventually run - no depedency issues at all. When I make a minor change is when things come apart! I forget which version of Xojo to use, since some do not work! This is what prompted last nights change by adding the Xojoversionstring.
I’ll recheck the unhandled exception, but I am pretty sure that this is part of the logging code…
I would try running a remote debugging session to the PI (is that available?) and see what happens in the debugger. If that won’t work, then add in system.log steps EVERYWHERE you can, particularly in the close and cancel close events. In fact, you may want to raise an exception in one of those events. Then in the unhandled exception event you can get the stack trace and see what is calling close.
One more comment - I remember having things like this happen and it would vary from Xojo version to Xojo version, but this was back when the web platform was really new. In the end, I believe the real problem with my app quitting all the time was that things were going out of scope when they shouldn’t have been. So make sure that whatever you need to keep the app up and going stays in scope.
This is not a web app that I am currently having trouble with - it is a console app.
There are no missing decencies either - since the last version worked perfectly, just added a few lines of code, which BTW, I removed to see if that was the issue!
An old backup copy of the app was just tested, it runs perfectly and stays running.
I’m going to try compiling on a Linux machine to see if that has any effect, to move on I hope so, but if that cures it, what a PIA!
I’ll try adding a raised event to make sure that the code in the unhandled exceptions gets run. Not sure if the remote debugger really works or not on Windows. I do not like using the Linux machine, it is cumbersome for me - 'cause I don’t use it!
In normal operation it starts automatically.
In these tests I cannot tell if it is stated auto then quits or not. But I do start manually double clicking on the file. Other versions work that way - including a backup which I just resorted to…
Console apps have no main thread. They run trough the Run event and then exit. You should have a while loop something like:
While Not App.Close
App.DoEvents(10)
App.MyMainLoopMethod
Wend
Return 0
Now you should create the App.MyMainLoopMethod as thats where your main loop code should go (keeps executing that, with yielding 10ms to the system after it.
Add a property App.Close As Boolean = False
Whe you set App.Close =True the app should automaticly quit.
Does it run any longer if you don’t daemonize the application?
You haven’t said much about what you are doing leading up to the main loop or what you are doing inside the main loop. Are you initializing the GPIO system or opening TCP Sockets in your application?
Try to get your application to run as a standard console application and then after everything checks out, daemonize it. In my experience, daemonizing is the final thing you want to do after getting the application stable.