简体   繁体   English

服务阻止Windows启动

[英]Service blocks windows startup

We have automatically started service which in some cases spends a lot of the time loading necessary data, let's say 10 minutes. 我们已经自动启动了服务,在某些情况下,该服务花费大量时间来加载必要的数据,例如10分钟。 During this time it works as expected (processing some huge data files required to start). 在这段时间内,它可以按预期工作(处理启动所需的一些巨大数据文件)。 I report the progess by C++ SetServiceStatus function, it is working fine. 我报告了C ++ SetServiceStatus函数的进展,它工作正常。

This service is not dependent on anything and has only one dependency which is again our own service. 这项服务不依赖任何东西,只有一个依赖关系,这也是我们自己的服务。 It is started after those 10 minutes, it needs the first "server" service to be fully running to accept the requests. 它在那10分钟之后启动,它需要第一个“服务器”服务才能完全运行以接受请求。

I thought that windows would start all other automatic services (in less then 10 minutes as usually) and then start working normally but system is completely blocked during startup (i can't login to computer or ping the computer) until this one specific service is started (reports SERVICE_RUNNING by SetServiceStatus). 我以为Windows会启动所有其他自动服务(通常在不到10分钟的时间内),然后开始正常工作,但是在启动过程中系统完全被阻止(我无法登录到计算机或ping计算机),直到此一项特定服务已启动(由SetServiceStatus报告SERVICE_RUNNING)。 When out service completely starts, the other missing system services (required for network, remote desktop, whatever, it's quite random) are also started. 当out服务完全启动时,还将启动其他缺少的系统服务(网络,远程桌面所需的服务,相当随机)。 Is this normal behaviour? 这是正常行为吗? Why are non-depending processes (as remote desktop, network connections, etc.) waiting for this process? 为什么非依赖进程(如远程桌面,网络连接等)正在等待该进程? Am I missing something? 我想念什么吗?

I tried to add some dependencies to postpone the startup of my service but I ended up with many dependencies and behaviour still somehow random (as order of services is random). 我试图添加一些依赖关系以推迟服务的启动,但是最终我得到了许多依赖关系,并且行为仍然以某种方式是随机的(因为服务的顺序是随机的)。 Sometimes I was able to login but for example Start button started working only after those 10 minutes when my service was started. 有时我可以登录,但是例如“开始”按钮仅在服务启动后的10分钟后才开始工作。 I am not sure what is "the last service" to depend on and what services to include to my depend-list and on some computers this services can be disabled and it can bring new problems... so I don't like this solution very much. 我不确定什么是“最后一项服务”以及要包含在我的依赖列表和某些计算机上的哪些服务可以禁用,并且会带来新的问题...所以我不喜欢这种解决方案非常。

Another option was Delayed start option for our service. 另一个选项是我们服务的“延迟启动”选项。 This should start service when all other automatic services are running. 当所有其他自动服务正在运行时,这应该启动服务。 Well, this works fine, windows boots, computer running and responding, our service is started, but the performance is very bad, many times slower than usually, it seems that delayed started services have much lower priority or something like that. 好吧,这可以正常工作,Windows启动,计算机运行并响应,我们的服务已启动,但性能非常差,比平时慢许多倍,看来延迟启动的服务的优先级低得多。

My only current solution is to report to system that my service is running (by SetServiceStatus function), but to continue loading (this works, I tested it). 我目前唯一的解决方案是向系统报告我的服务正在运行(通过SetServiceStatus函数),但是继续加载(此方法有效,我对其进行了测试)。 But then we have problem with our dependent service as it needs to be started when the first one is really ready. 但是随后我们的依存服务出现了问题,因为它需要在第一个服务真正准备好时就启动。 It can be solved but I still wonder how is this possible and if there is something I could use to keep the current state of automatic started service which reports "started" when it is really fully started and prepared to work. 它可以解决,但我仍然想知道这是怎么可能的,是否可以使用某种方式来保持自动启动服务的当前状态,该状态在真正完全启动并准备工作时会报告“已启动”。 Thanks for any ideas. 感谢您的任何想法。

Set SERVICE_RUNNING as soon as possible, and then continue processing in background. 尽快设置SERVICE_RUNNING,然后在后台继续处理。 Make your other service resilient to the first service being in a running state, but not yet ready to service. 使您的其他服务对正在运行但尚未准备好服务的第一个服务具有弹性。 The longer the service is in the starting state the more problems we get from different windows versions. 服务处于启动状态的时间越长,我们从不同Windows版本获得的问题就越多。

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

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