Merge branch 'development'

This commit is contained in:
Thomas Williams 2024-07-07 18:36:06 +01:00
commit e7726fb77c
2 changed files with 60 additions and 20 deletions

76
main.py
View file

@ -22,29 +22,20 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import config
import psutil
import os
import time
import log
import requests
import threading
import signal
import socket
from functools import partial
from concurrent.futures import ThreadPoolExecutor, as_completed
from bs4 import BeautifulSoup
from log import logsManager
from datetime import datetime
def get_pip_command():
if sys.version_info >= (3, 0):
if config.loggingMode == 'rabbitmq':
return 'pip3'
import rabbitmq
rabbitmq = rabbitmq.rabbitMQClient(config.rabbitmqca,config.rabbitmqcacert,config.rabbitmqcakey,config.rabbitmqHost,config.rabbitmqPort,config.rabbitmqRoutingKey)
else:
stop_event = threading.Event()
nonPOSIXCPULoads = []
lock = threading.Lock()
return 'pip'
def install_dependencies():
pip_command = get_pip_command()
subprocess.check_call([pip_command, 'install', '-r', 'requirements.txt', '--user'])
def signal_handler(sig, frame):
print('SIGINT/SIGTERM aknowledged. Stopping script gracefully, please wait...')
@ -199,6 +190,21 @@ def logURLLog(hostname, logTime, url, responseTime):
def main():
if sys.platform.startswith('win'):
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)
install_dependencies()
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)
@ -212,4 +218,34 @@ def main():
urlMonitorThread.join()
if __name__ == "__main__":
import sys
import subprocess
install_dependencies()
import config
import psutil
import os
import time
import log
import requests
import threading
import signal
import socket
from functools import partial
from concurrent.futures import ThreadPoolExecutor, as_completed
from bs4 import BeautifulSoup
from log import logsManager
from datetime import datetime
if config.loggingMode == 'rabbitmq':
import rabbitmq
rabbitmq = rabbitmq.rabbitMQClient(config.rabbitmqca,config.rabbitmqcacert,config.rabbitmqcakey,config.rabbitmqHost,config.rabbitmqPort,config.rabbitmqRoutingKey)
stop_event = threading.Event()
nonPOSIXCPULoads = []
lock = threading.Lock()
main()

4
requirements.txt Normal file
View file

@ -0,0 +1,4 @@
psutil
requests
bs4
datetime