4

I have a background (headless) app set to start at StartUp but after long execution sometimes the app stops. Clearly I need to investigate this stoppage, but I would like this app to run like a windows service, so that if it stops for ANY reason, the windows runtime should start the app up again.

I am about to investigate a script or separate app running on a timer to check if the main process is running and restart if necessary but I was under the impression that this auto-restart was a feature of the IoT Core runtime.

Does anyone know how to get background apps to restart automatically after failure or of a simple solution to replicate this functionality?

  • I think the latest Insider version has scheduled tasks.. You could put something in there to check your app, if its dead then restart it. Services are also on the way.. its all in the pipelines. Another way is to make the app default, if it crashes it should automatically start up. – Piotr Kula Apr 25 '17 at 12:22
  • Thanks @ppumkin I have already set the app as "StartUp" in the device portal, which is how you set it as the default app. I will look into tasks, but Caleb Forti's answer raspberrypi.stackexchange.com/a/66313/63513 is what I was looking for. I just assumed that background apps were supported in this way as well. – Chris Schaller Apr 26 '17 at 4:26
3

March 2017 release notes has the following statement regarding crashes and restarts:

Shell Management of Application Crashes

IoT Core’s shell infrastructure monitors APPX-type applications running on the device for crashes, and restarts those applications when crashes occur. If the restarted applications continue to crash, the shell will employ a __failfast – a system critical process that causes a bugcheck and reboot in an attempt to recover. Comparable logic and handling is used to background tasks and foreground applications in a headed configuration.

From the wording in the release notes it sounds as your expected functionality only works for headed apps, so then the solution would be to convert your app to a headed app and be done with it.

Even if your device is not intended for a user to plug a screen in, adding a user interface would open up on-site debug and configuration options that could help turn your rustic background service into an enterprise ready application.

0

I was about to post: Go for supervisord... but then I realised the problem here.

A few (im-)possible options:

  • run as a Windows Service and use the Service Control Manager (SCM) to monitor and restart it, see here:

    If your process is implemented as a Service, then the Service Control Manager (SCM) will monitor it and can automatically restart it when it crashes. See the documentation here: SERVICE_FAILURE_ACTIONS structure.

    If for some reason you cannot implement your process as a Service, you can write a new Service that "wraps" the process and get the same behavior. The srvany.exe tool in the Resource Kit will do this for generic processes. How To Create a User-Defined Service

    There is no indication that Windows 10 IoT Core is devoid of the SCM and related functionality. Key is the SERVICE_FAILURE_ACTIONS structure.

  • no option use supervisord with cygwin as suggested here. However, it would seem that cygwin is not working on IoT core, see here:

    So is it possible to do something like install cygwin on Windows IoT on my Raspberry Pi, compile my test using gcc and execute them?

    unsupported and you will not find cygwin or gcc for Windows IoT Core and ARM

  • Does WinIoT have SCM? Is it possible to use cygwin on WinIoT? (I wonder if it will get LInux Subsystems) - I am not really sure Unix styled services will be helpful on Windows OS? Seems all hypothetical here- DId you manage to get on of those going? – Piotr Kula Apr 26 '17 at 7:39
  • @ppumkin as stated in my answer cygwin is not working and I did not find any clues that IoTCore does not provide SCM. If you know it does not, please say so. Until then this is at least a pointer into a direction worth investigating (for anybody who is interested in this topic). Whether that's hypothetical or not is probably in the eye of the beholder. – Ghanima Apr 26 '17 at 17:10
  • I really like your answers on this site but this one seems to be quite confusing to be honest.. Not trying to be mean or anything - Just as a Windows power user I have trouble understanding this answer – Piotr Kula Apr 26 '17 at 20:41
  • I see your point. Do you (as a power user) have any definite knowledge wether the SCM works on IoTcore or not? – Ghanima Apr 27 '17 at 4:53
  • From what I understand it does not exist.. but is in the pipeline of features to be implemented. – Piotr Kula Apr 27 '17 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.