-
Notifications
You must be signed in to change notification settings - Fork 311
Make the way configurable how hosting is kept alive #129
Conversation
What does MyHostingKeepAlive look like? Why wouldn't we bake this into hosting in general? |
Some background on service killing with systemd: http://www.freedesktop.org/software/systemd/man/systemd.kill.html Sample Hold()-implementation with Mono.Posix: public void Hold()
{
var unixSignal = new UnixSignal(Mono.Unix.Native.Signum.SIGTERM);
unixSignal.WaitOne();
} |
With regards to a notification on successful startup, another scenario is notifying systemd that the process finished starting up. The cleanest solution is to acquire a D-Bus name once the process is done booting up. |
This is the exact issue that I wanted to address with aspnet/dnx#494. Seems to me that hosting indeed needs to be configurable as this is probably something that will differ for each hosting platform... |
@Tragetaschen can you please get this rebased on top of the |
Sure |
Thanks for rebasing! We have a bot that checks for CLAs on PRs. Since this PR is pretty old, the bot did not analyze it. Can you please close this PR and recreate it? |
He's good to go. He's a regular in these here parts |
👍 then I'll merge this today |
Here is a sample implementation when being hosted on Linux using systemd. |
I would rename Hold to WaitForSignal or Wait |
Also /cc @lodejard on this to see if he likes the interface |
I was thinking about turning this into a Task-returning *Async method and reworking the shutdown-logic in Program.cs to
That way, the error handing during shutdown can also be simplified. Regarding the name of the method, I'm not happy either. The problem is that the interface and the method describe the same thing, one as a noun and the other using a verb. A "logical" choice would be |
I really like this change but I don't think it needs to be an entirely new service. Let's see what it would be like if a property was added to The ApplicationStarted is more of an event than a blocking or async method. The default Action should be the lines:
|
An assignable action looks weird. Event? Also how do I make sure the application exists if any signal is tripped |
I have implemented my sketch and updated the sample. I do understand the tendency to not make this an interface. It's just for one method and the cost of documenting is non-trivial. But I think the alternatives will look weird when applied in an actual application:
In the end, how the application keeps running is an orthogonal concept to anything else and I think this justifies an interface on its own. |
@lodejard , @davidfowl can we please close on this and get a final design/solution? It is blocking the Nano Server runs... |
Maybe I'm crazy, or just getting used to Lou, but I think I like the assignable action better too... Although it would be nice if we had some sugar/overloads to simplify it down to just the inner real Action?:
|
@Tragetaschen, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
I'm currently trying to host on Linux and integrated into systemd as init system. The fixed default of Console.ReadLine() to keep the hosting running does not work well and I would like to change this in my application so I can react properly to SIGTERM on Linux. This PR adds an interface and the current default implementation to Hosting.
Within a web application, this default can be overridden by