首页 > 解决方案 > Startup of IHostedService's in ASP.NET Core

问题描述

  1. Are container-registered IHostedService's started in parallell or sequential?

  2. Are the startups waited on before accepting incoming request?

  3. If the startup crashes, how can this be detected? It seem to swallow this.

  4. If a service crashes during operation, can it be configured to restart automatically?

标签: asp.net-core

解决方案


经过一番研究,我想我可以自己回答其中的大部分问题:

  1. 它们似乎是按照注册的顺序开始的,而不是并行的。
  2. 不等待 StartAsync 并且在 StartAsync 完成之前处理请求(可以通过自定义中间件缓解)。
  3. 如果 StartAsync 崩溃,它将被忽视(我在某处读到的内容显然应该在未来的版本中修复)。
  4. 如果在操作过程中崩溃,这也会被忽视,而且我还没有找到使用配置重新启动它们的方法,尽管制作自定义管理器来重新启动它们应该相当容易。

推荐阅读