Closes issue #23
This commit is contained in:
parent
48abfbba8c
commit
7086eeac1b
1 changed files with 12 additions and 2 deletions
14
main.py
14
main.py
|
@ -31,6 +31,7 @@ import requests
|
||||||
import threading
|
import threading
|
||||||
import signal
|
import signal
|
||||||
import socket
|
import socket
|
||||||
|
import sys
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
@ -199,8 +200,17 @@ def logURLLog(hostname, logTime, url, responseTime):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
signal.signal(signal.SIGTERM, signal_handler)
|
if sys.platform.startswith('win'):
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
|
||||||
|
import win32api
|
||||||
|
|
||||||
|
win32api.SetConsoleCtrlHandler(lambda sig, frame:
|
||||||
|
|
||||||
|
signal_handler(signal.CTRL_C_EVENT, frame), True)
|
||||||
|
else:
|
||||||
|
|
||||||
|
signal.signal(signal.SIGTERM, signal_handler)
|
||||||
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
hostMonitorThread = threading.Thread(target=monitorHost, args=(stop_event,))
|
hostMonitorThread = threading.Thread(target=monitorHost, args=(stop_event,))
|
||||||
urlMonitorThread = threading.Thread(target=monitorUrls, args=(stop_event,))
|
urlMonitorThread = threading.Thread(target=monitorUrls, args=(stop_event,))
|
||||||
|
|
Loading…
Reference in a new issue