을 반드시 smf있다
솔라리스 launchd에있다
(무례한)은 다음의 코드는이 검사를 /etc/event.d있다은/etc/보유 지정된 간격에서 주어진 프로세스를 재시작하고 다시 시작합니다.
#Restarts a given process if it is finished.
#Compatible with Python 2.5, tested on Windows XP.
import threading
import time
import subprocess
class ProcessChecker(threading.Thread):
def __init__(self, process_path, check_interval):
threading.Thread.__init__(self)
self.process_path = process_path
self.check_interval = check_interval
def run (self):
while(1):
time.sleep(self.check_interval)
if self.is_ok():
self.make_sure_process_is_running()
def is_ok(self):
ok = True
#do the database locks, client data corruption check here,
#and return true/false
return ok
def make_sure_process_is_running(self):
#This call is blocking, it will wait for the
#other sub process to be finished.
retval = subprocess.call(self.process_path)
def main():
process_path = "notepad.exe"
check_interval = 1 #In seconds
pm = ProcessChecker(process_path, check_interval)
pm.start()
print "Checker started..."
if __name__ == "__main__":
main()
모니터중인 프로그램 세트의 고유 한 속성으로 인해 데몬으로 만들 수 없습니다. 따라서 기존의 모니터링 방법을 사용할 수 없습니다. 또한 나는 외부 코드에 의존하기보다는 멋진 모듈 하나를 구현하는 것이 더 편하다고 느낄 수있는 특정 기능이 필요합니다. /proc/
Caedis