Windows 服务故障排除、恢复设置?

发布于 2024-07-16 19:32:43 字数 318 浏览 9 评论 0原文

现在我在 Windows Server 2003 上有某种服务应用程序,用于将设备中的数据输入数据库。

有时服务会由于数据错误或其他任何原因(数据库连接问题、互联网连接中断等)而失败,我必须重新启动服务,现在我针对此问题提供的解决方案是使用 NET START/STOP 命令的简单批处理命令每 1 小时安排一次。

然后我看一下服务属性上的恢复选项卡,有一个重新启动服务的选项,我想知道如何测试它? 例如,Windows如何知道服务失败了? 最重要的是,当发生故障时,如何知道服务已成功重启(基于恢复设置)?

PS:我无法访问代码,

谢谢

Right now i have some sort of services application on windows server 2003 for inputting data from devices into database.

Sometimes the services fail due to data error or anything else (database connection problem, internet connection down, etc) which i have to restart the services, right now the solution i provide for this problem was a simple batch command using NET START/STOP command that scheduled every 1 hour.

I then take a look at recovery tab on service properties, there was an option to restart the services, which i want to know was how to test it? Such as, how Windows know the services was failed? And the most important was how to know that services successfully restarted when failure occur (based on recovery setting)?

PS: I didn't have access to the code

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

弥繁 2024-07-23 19:32:43

当服务因未处理的异常而崩溃时,服务控制台的自动重新启动就会启动。 (代码的某些部分抛出异常,但没有任何东西捕获它,并且它一直向上冒出主函数。)

如果您可以控制代码,那么最好放入一些 try/catch 块围绕容易引起问题的区域并更优雅地处理错误。 您还可以在应用程序的主入口点周围放置一个 try/catch,以捕获并尝试处理代码中任何未处理的异常。

如果您无法控制代码,您可以通过强制发生这些错误之一来测试自动服务恢复。 如果出现连接问题导致服务崩溃,您可以通过拔掉计算机上的网络电缆来强制执行此操作。

The service console's auto restart kicks in when a service crashes from an unhandled exception. (Some part of your code throws an exception, but nothing catches it, and it bubbles all the way up and out of the main function.)

If you have control over the code, it might be better to put in some try/catch blocks around the areas that tend to cause problems and handle errors more gracefully. You could also put a try/catch around the main entry point of the application, to catch and try to handle any unhandled exceptions from the code.

If you can't control the code, you can test the auto service recovery by forcing one of these errors to occur. If you service crashes in the event of a connection problem, you can force this by unplugging the network cable on the computer.

乱了心跳 2024-07-23 19:32:43

测试恢复选项的最简单方法是从任务管理器终止服务进程。 Windows 将检测到它并运行“首次故障”恢复选项。 后续击杀将测试“第二次失败”和“后续失败”选项。 事件日志将记录退出和所采取的操作。

根据您的环境和服务,这对于您来说可能是也可能不是一个可行的选择,因为您正在终止该服务。

The easiest way to test the recovery options is to kill your service's process from the task manager. Windows will detect it and run the First Failure recovery option. Subsequent kills will test the Second Failure and Subsequent Failure options. The Event Log will note the exit and the actions taken.

Depending on your environment and your service this may or may not be a viable option for you as you are killing the service.

紫轩蝶泪 2024-07-23 19:32:43

您可以将其恢复到较早的时间点,恢复 Surface 不会更改您的个人文件,但可能会删除最近安装的应用程序和驱动程序。

1.从屏幕右边缘扫入,然后点击搜索。
(如果您使用鼠标,请指向屏幕右上角,向下移动鼠标指针,然后单击“搜索”。)

2. 在搜索框中输入“控制面板”,然后点击或单击“控制面板”。

3. 在控制面板搜索框中输入“恢复”,然后点击或单击“恢复”。

4.点击或单击“打开系统还原”,然后按照说明进行操作。

You can restore it back to an earlier point in time, Restoring Surface doesn’t change your personal files, but it might remove recently installed apps and drivers.

1.Swipe in from the right edge of the screen, and then tap Search.
(If you're using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, then click Search.)

2.Enter Control Panel in the search box, and tap or click Control Panel.

3.Enter Recovery in the Control Panel search box, and then tap or click Recovery.

4.Tap or click Open System Restore, and then follow the instructions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文