user should be able to leave app and have onionservice / http service continue to run
Closed this issue · 4 comments
- even if just briefly for a few minutes
- warn them to return to app if it is going to shutdown
See #1.
Keeping the lights on is an ugly, battery-draining hack , but the only way. Will implement that.
Ah, misunderstanding in the late evening. You're talking about background operations.
That's already included:
https://github.com/swisspol/GCDWebServer#gcdwebserver--background-mode-for-ios-apps
For the notification part:
I'll try something. Not sure if that's going to work, sending user notifications from the background.
Ok, notifications work just fine from the background.
However, it's not staying alive very long, currently.
Our own background thread just sleeps, that might be detected. Need to do some useless calculation there, maybe. More battery to drain :-(
GCDWebServer
is quick to tell the OS, that it's done, too, after all requests were fulfilled.
https://github.com/swisspol/GCDWebServer/blob/master/GCDWebServer/Core/GCDWebServer.h#L186-L193
I tuned this parameter to 10 seconds, but I'm afraid I can't do more, because then I couldn't do #10 anymore. That option is also used in the detection when a download is considered "finished".
So, I refined this a little more. Tried asking less about rest of time, tried getting CPU busy. Nothing helped. I only ever got 30 seconds. Might be because debug. Other resources say 3 minutes are typical.
It now notifies the user between 15 and 10 seconds before shutdown. Don't think that can get any better.
Funny side note about keeping the CPU busy:
I tried Fibonacci and it was either 30% load but with a recursion limit or tail-call-optimized through the compiler with 0% load. D'oh!