Monitor: Add 'are you running this correctly?' check

This commit is contained in:
Athanasius 2022-03-18 14:25:19 +00:00
parent 3f024f965c
commit 86cfed0ec5
No known key found for this signature in database
GPG Key ID: 8C392035DD80FD62

View File

@ -5,10 +5,30 @@ import argparse
import collections import collections
import datetime import datetime
import logging import logging
import sys
import zlib import zlib
from threading import Thread from threading import Thread
from typing import OrderedDict from typing import OrderedDict
if sys.path[0].endswith('/eddn'):
print(sys.path)
print(
'''
You're not running this script correctly.
Do not do:
python <path to>/Monitor.py <other arguments>
instead do:
cd <src directory>
python -m eddn.Monitor <other arguments>
'''
)
sys.exit(-1)
import gevent import gevent
import mysql.connector as mariadb import mysql.connector as mariadb
import simplejson import simplejson
@ -19,6 +39,7 @@ from zmq import SUB as ZMQ_SUB
from zmq import SUBSCRIBE as ZMQ_SUBSCRIBE from zmq import SUBSCRIBE as ZMQ_SUBSCRIBE
from eddn.conf.Settings import Settings, load_config from eddn.conf.Settings import Settings, load_config
from eddn.core.EDDNWSGIHandler import EDDNWSGIHandler
monkey.patch_all() monkey.patch_all()
@ -41,14 +62,12 @@ if Settings.RELAY_DUPLICATE_MAX_MINUTES:
duplicate_messages = DuplicateMessages() duplicate_messages = DuplicateMessages()
duplicate_messages.start() duplicate_messages.start()
from eddn.core.EDDNWSGIHandler import EDDNWSGIHandler
def parse_cl_args(): def parse_cl_args():
"""Parse command-line arguments.""" """Parse command-line arguments."""
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
prog="Gateway", prog="Monitor",
description="EDDN Gateway server", description="EDDN Monitor server",
) )
parser.add_argument( parser.add_argument(