import logging
import os
import random
import string
import sys

from Classes.System.Server import Server
from Classes.System.Logger import Logger

def get_random_string(length) -> str:
    # choose from all lowercase letter
    letters = string.ascii_lowercase
    result_str = ''.join(random.choice(letters) for i in range(length))
    print("Random string of length", length, "is:", result_str)
    return result_str

def main():
    # retrieves host data from environment
    HOST = "127.0.0.1"
    TCPPORT = "54322"
    UDPPORT = "54323"

    logger = Logger("log/"+get_random_string(8)+".log")
    logger.info("starting up server")
    server = Server(HOST, TCPPORT, UDPPORT, logging)
    server.getNetworkManager().tcp.stop()
    sys.exit(0)

if __name__ == "__main__":
    main()