Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Send graceful shutdown notification via HTTP #115

Closed
Tratcher opened this issue Jun 22, 2017 · 9 comments
Closed

Send graceful shutdown notification via HTTP #115

Tratcher opened this issue Jun 22, 2017 · 9 comments
Assignees
Milestone

Comments

@Tratcher
Copy link
Member

RE: aspnet/Hosting#846

Today ANCM sends CTL+C to notify the child process of graceful shutdowns. This triggers shutdown events in Hosting, stops the server, drains requests, etc.. Unfortunately Azure Web Sites sandbox blocks all out-of-proc console APIs, including CTL+C. Sending the signal fails with an error and ANCM immediately terminates the child process.

Proposal:
ANCM will now send this notification via an HTTP request that will be handled by the IISMiddleware. The CTL+C will remain for back compat. We need to confirm if the debugger tooling is expecting this CTL+C.

Note 1.x sites on azure will not be fixed by this solution, only 2.x apps + a new ANCM.

Order of operations:

  • Start the shutdown timer
  • Send the HTTP shutdown request, wait for response.
  • Send the CTL+C.
  • If both failed, log the failure and terminate the process immediately
  • Otherwise wait for the process to end.
  • If the timeout expires then terminate the process and log the failure, including any notes on if the shutdown request returned the expected response.

Request details:
POST [/BasePath]/iisintegration HTTP/1.1
MS-ASPNETCORE-EVENT: shutdown
(no body)

Expected response:
HTTP/1.1 202 Accepted
(no body)

Other notes:
ANCM already filters out an external MS-* headers.
IISMiddleware already rejects requests missing the MS-ASPNETCORE-TOKEN header.
IISMiddleware is only added to the app if ANCM environment variables are present at startup.

@JunTaoLuo
Copy link

IISIntegration change is in.

@DamianEdwards
Copy link
Member

@shirhatti @pan-wang do we have an ETA and release plan for this change?

@pan-wang
Copy link
Contributor

pan-wang commented Jun 28, 2017 via email

@Plasma
Copy link

Plasma commented Jul 19, 2017

Hi team, any update on whether this change was rolled out to Azure AppService to support graceful shutdowns? Thank you

@Tratcher
Copy link
Member Author

The change requires both a new version of ANCM and the final release of ASP.NET Core 2.0. Both are scheduled for release and azure deployment in the coming weeks.

@pan-wang
Copy link
Contributor

the change was checked in. Close the issue

@rollsch
Copy link

rollsch commented Oct 30, 2017

What libraries and versions specifically do I need to ensure I have this new change?

@shirhatti
Copy link
Contributor

ANCM >= 1.0.1983
Microsoft.AspNetCore.IISIntegration (or Microsoft.AspNetCore.All) >= 2.0.0

@rollsch
Copy link

rollsch commented Oct 31, 2017

Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants