When using a DNX(core) ASP.NET 5 application, the Configure() method can be used to subscribe to the following cancellation events:
当使用DNX(core) ASP时。NET 5应用程序,Configure()方法可用于订阅以下取消事件:
IApplicationLifetime::ApplicationStarted
IApplicationLifetime::ApplicationStopping
IApplicationLifetime::ApplicationStopped
However, the only way I can see ATM to properly terminate an application is to call
但是,我能看到ATM正确地终止应用程序的唯一方法是调用。
IApplicationLifetime::StopApplication()
from within the application or press CTRL+C using Kestrel and running in a console.
在应用程序内部或使用Kestrel按CTRL+C并在控制台运行。
Obviously the target here is to host the application as a background application (ideally as a cloud deployment).
显然,这里的目标是将应用程序作为后台应用程序(理想情况下是作为云部署)托管。
Unfortunately I haven't been able to get a demo application to run on IIS. When using IBM BlueMix, I've noticed that the stopping and stopped events are never fired and apparently the application is just stopped.
不幸的是,我还没能在IIS上运行演示应用程序。在使用IBM BlueMix时,我注意到停止和停止事件不会被触发,显然应用程序也会停止。
What is the proper way to deal with this? Are these events unreliable or am I doing something wrong?
如何处理这个问题?这些事件是不可靠的还是我做错了什么?
Help is greatly appreciated. Thanks in advance!
非常感谢您的帮助。提前谢谢!
1 个解决方案
#1
1
Right now, it's not possible to detect when the process is being killed.
目前,无法检测进程何时被终止。
There's 2 ways that even is going to fire as of now.
到目前为止,有两种方式会发生火灾。
- CTRL-C in the console window of Kestrel
- 在Kestrel的控制台窗口中按CTRL-C
- The
Application
is being disposed. - 应用程序正在被处理。
As far as it seems, they will have something ready when they hit RTM.
就目前看来,当他们点击RTM时,他们会准备好一些东西。
As for when a process gets killed, if BlueMix is closing on windows, it should send the proper WM_Close
(0x0010) event and SIGTERM
if you are under a Linux/OSX system.
至于进程被终止时,如果BlueMix正在windows上关闭,那么如果您在Linux/OSX系统下,它应该发送适当的WM_Close (0x0010)事件和SIGTERM。
If BlueMix is sending SIGKILL
, then there's nothing that can be done about events.
如果BlueMix正在发送SIGKILL,那么对事件就无能为力了。
LIBUV Update:
LIBUV更新:
After digging a bit deeper, if you have any control over the signals that are sent, I recommend not sending any of those: SIGILL
, SIGABRT
, SIGFPE
, SIGSEGV
, SIGTERM
and SIGKILL
.
在深入挖掘之后,如果您对发送的信号有任何控制,我建议您不要发送这些信号:SIGILL、SIGABRT、SIGFPE、SIGSEGV、SIGTERM和SIGKILL。
ASP.NET 5 is based on libuv and they might be limited to SIGINT
or SIGHUP
to terminate the application since libuv will not allow you to handle SIGTERM
.
ASP。NET 5基于libuv,它们可能仅限于SIGINT或SIGHUP来终止应用程序,因为libuv不允许您处理SIGTERM。
#1
1
Right now, it's not possible to detect when the process is being killed.
目前,无法检测进程何时被终止。
There's 2 ways that even is going to fire as of now.
到目前为止,有两种方式会发生火灾。
- CTRL-C in the console window of Kestrel
- 在Kestrel的控制台窗口中按CTRL-C
- The
Application
is being disposed. - 应用程序正在被处理。
As far as it seems, they will have something ready when they hit RTM.
就目前看来,当他们点击RTM时,他们会准备好一些东西。
As for when a process gets killed, if BlueMix is closing on windows, it should send the proper WM_Close
(0x0010) event and SIGTERM
if you are under a Linux/OSX system.
至于进程被终止时,如果BlueMix正在windows上关闭,那么如果您在Linux/OSX系统下,它应该发送适当的WM_Close (0x0010)事件和SIGTERM。
If BlueMix is sending SIGKILL
, then there's nothing that can be done about events.
如果BlueMix正在发送SIGKILL,那么对事件就无能为力了。
LIBUV Update:
LIBUV更新:
After digging a bit deeper, if you have any control over the signals that are sent, I recommend not sending any of those: SIGILL
, SIGABRT
, SIGFPE
, SIGSEGV
, SIGTERM
and SIGKILL
.
在深入挖掘之后,如果您对发送的信号有任何控制,我建议您不要发送这些信号:SIGILL、SIGABRT、SIGFPE、SIGSEGV、SIGTERM和SIGKILL。
ASP.NET 5 is based on libuv and they might be limited to SIGINT
or SIGHUP
to terminate the application since libuv will not allow you to handle SIGTERM
.
ASP。NET 5基于libuv,它们可能仅限于SIGINT或SIGHUP来终止应用程序,因为libuv不允许您处理SIGTERM。