最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论