简体   繁体   English

我可以在 IIS 中托管 Worker Service 项目吗?

[英]Can I host a Worker Service project in IIS?

In Visual Studio 2019, I can setup a new project of type "Worker Service", which sets up a console application for long running worker processes.在 Visual Studio 2019 中,我可以设置一个“Worker Service”类型的新项目,它为长时间运行的工作进程设置一个控制台应用程序。

I can host these Worker Services in Docker or as Windows Service (with additional code), but my question is:我可以在 Docker 中或作为 Windows 服务(带有附加代码)托管这些 Worker 服务,但我的问题是:

Can I host a Worker Service project in IIS?我可以在 IIS 中托管 Worker Service 项目吗?

As far as I know, it may difficult.据我所知,这可能很困难。 If you check document about worker service, Microsoft doesn't suggest you do that because there is no any word about host worker service on IIS.如果您查看有关工作人员服务的文档,Microsoft 不建议您这样做,因为 IIS 上没有关于主机工作人员服务的任何信息。

Actually, if any application can host or Microsoft suggest users host on IIS, you can see "IIS Express" in VS.实际上,如果有任何应用程序可以托管或微软建议用户在 IIS 上托管,您可以在 VS 中看到“IIS Express”。 However, you cannot see that when create a worker service application.但是,您在创建工作服务应用程序时看不到这一点。 在此处输入图片说明

However, deveploer in this thread can achieve what you want.但是, 该线程中的deveploer 可以实现您想要的。 Just some strange issues happened.只是发生了一些奇怪的问题。

After a couple more months of using this configuration, it becomes clear that it will sometimes behave in slightly curious ways - for example starting multiple instances of the same thread - and it can generally be a little quirky.使用此配置几个月后,很明显它有时会以稍微奇怪的方式运行 - 例如启动同一线程的多个实例 - 它通常有点古怪。 It also isn't necessarily any easier to troubleshoot than a regular windows service, although it probably is easier to deploy.它也不一定比常规的 Windows 服务更容易进行故障排除,尽管它可能更容易部署。

As a conclusion, you can do that but it is not recommended.总之,您可以这样做,但不建议这样做。 Especially once something goes wrong, it's hard to troubleshoot.尤其是一旦出现问题,就很难排除故障。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM