.net core - How do I configure Kestrel to ignore shutdown (CancellationTokenSIGTERM) - Stack Overflow

My background service app is running a self-hosted REST API that exposes information. The app handles s

My background service app is running a self-hosted REST API that exposes information. The app handles shutdown gracefully, but sometimes it can take significant amount of time to finish.

I've configured it this way:

builder.Host.ConfigureHostOptions(options =>
{
    options.ShutdownTimeout = TimeSpan.FromMinutes(30);
});

I am fully understanding that the host OS or hardware might shut down well before that, and that's totally acceptable to me. What I need, however, is that the REST API remains up and running for as long as the app is not terminated. Effectively ignoring the shutdown signal. Or ideally, making it dependent on the another IHostedService's lifespan. i.e. I want to keep the API up and running for as long as the other hosted service is running, since it's the one handling the main work and therefore the graceful shutdown.

How do I achieve that?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744689626a4588131.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信