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?