Pivotal Knowledge Base


Graceful Shutdown of .NET apps in Cloud Foundry Windows


PCF Runtime for Windows (1.9, 1.10, 1.11, 1.12)

Pivotal Application Service for Windows 2012R2 (PAS for Windows 2012R2)

Pivotal Application Service for Windows (PAS for Windows)


For .NET and Windows apps that need to have a graceful shutdown process, this article explains the behavior of shutdown process running on Windows cells based on Windows Server 2012 R2 and Windows Server 2016.


Stopping (e.g. cf stop or cf delete) applications on Windows 2012 R2 cells can leave behind ghost connections and pending transactions which could lead to the application in an inconsistent state.


The behavior of app shutdown will differ based on whether you are using Windows Server 2012 R2 or Windows Server 2016 stemcell.

2012 R2 shutdown characteristics

For .NET applications hosted on Runtime for Windows or PAS for Windows 2012R2, application processes are forcefully terminated on Windows Server 2012 R2.

This is due to a known limitation of the IronFrame containerization framework used in these products, and there is no known workaround or fix.

See the original public tracker story documenting this behavior: https://www.pivotaltracker.com/story/show/153491349

2016 shutdown characteristics

On PAS for Windows, which currently uses only Windows Server 2016 (version 1709), there is no IronFrame process and thus does not carry the limitations of that framework. Instead, PAS for Windows takes advantage of the native Windows Server Container technology, which affords a graceful shutdown by default.

To leverage the graceful shutdown characteristics of Windows 2016, .NET and Windows-based applications may handle CTRL_CLOSE_EVENT as well as CTRL_SHUTDOWN_EVENT system events. Note that the timing for these events does not match that for Linux applications.

For more details, this public tracker story: https://www.pivotaltracker.com/story/show/153929985

Additional Information

[1] https://docs.cloudfoundry.org/devguide/deploy-apps/app-lifecycle.html#shutdown

[2] https://docs.microsoft.com/en-us/windows/console/generateconsolectrlevent

[3] https://docs.microsoft.com/en-us/windows/console/setconsolectrlhandler


Powered by Zendesk