71 lines
2.0 KiB
Python
71 lines
2.0 KiB
Python
import os, sys
|
|
import time
|
|
import logging
|
|
import traceback
|
|
|
|
# TODO NOT SURE IF SYS PATH IS A GOOD PRACTICE
|
|
root_dir = os.path.normpath(__file__.split("libs")[0])
|
|
sys.path.append(root_dir)
|
|
|
|
from libs.app.utils import Utils, kargs_to_array, get_logger, is_http_running, config_root_logger
|
|
|
|
logger = None
|
|
try:
|
|
config_root_logger()
|
|
logger = get_logger()
|
|
utils = Utils()
|
|
except Exception:
|
|
logging.exception("ERROR")
|
|
|
|
from libs.app.updater import Updater
|
|
|
|
def main():
|
|
log_ascii_art()
|
|
logger.debug(f"Readable params: {kargs_to_array()}")
|
|
|
|
if not is_noSys_running():
|
|
updater = Updater(utils)
|
|
utils.configs.read_packages()
|
|
|
|
from libs.noSys.noSysCore import NoSysCore
|
|
noSys = NoSysCore(updater)
|
|
else:
|
|
logger.debug(f"NoSys already running")
|
|
# TODO open url frontend
|
|
|
|
logger.info(f"---------------- Main ended ----------------")
|
|
|
|
def is_noSys_running():
|
|
try:
|
|
api_config = utils.configs.packages["api"].config
|
|
api_port = api_config["server"]["port"]
|
|
api_health_check_url = f"http://localhost:{api_port}/api/health"
|
|
logger.debug(f"Checking url: {api_health_check_url}")
|
|
return is_http_running(api_health_check_url)
|
|
except Exception:
|
|
logger.exception("ERROR")
|
|
|
|
def log_ascii_art():
|
|
logger.info("""
|
|
_ __ ____
|
|
/ |/ /__ / __/_ _____
|
|
/ / _ \ _\ \/ // (_-<
|
|
/_/|_/\___/ /___/\_, /___/
|
|
/___/
|
|
|
|
Every man must have freedom, must have the scope to form, test, and act upon his own choices, for any sort of development of his own personality to take place. He must, in short, be free in order that he may be fully human.
|
|
- Murray Rothbard
|
|
|
|
""")
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
main()
|
|
time.sleep(30)
|
|
except Exception:
|
|
logger.exception("ERROR")
|
|
for sec in range(30):
|
|
logger.info(f"Closing in {30-sec}")
|
|
time.sleep(1)
|
|
|