python运行代码无反应_检查进程状态,如果无响应/已停止,则重新启动进程-Python...

1586010002-jmsa.png

I'm trying to build a small process monitoring script on Windows Server 2008.

The script would:

find target process

check status (running/unresponsive/stopped)

kill and restart process if unresponsive/stopped

Any suggestion on the best way to implement this?

解决方案

Naming a process 'unresponsive' is quite subjective. It might be waiting for data and seem unresponsive, or it might be in a (endless) loop and seem unresponsive.

Usually, what people do is implement hartbeat. That is - have a very tiny socket server in the process where other processes can connect and send ping messages, to which it replies pong. What monitoring tools usually do is ping the process periodically, and if it doesn't respond within a timeout - it's considered unresponsive (and usually gets killed).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值