37 lines
771 B
Python
37 lines
771 B
Python
|
from importlib import reload
|
||
|
|
||
|
import sys
|
||
|
|
||
|
import socket
|
||
|
import json
|
||
|
|
||
|
from objects import glob
|
||
|
from objects.server import Server
|
||
|
|
||
|
from objects import client
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
print("> Loading config")
|
||
|
with open("config.json", "r") as f:
|
||
|
glob.config = json.load(f)
|
||
|
|
||
|
print("> Starting server")
|
||
|
glob.server = Server(glob.config["host"], glob.config["port"])
|
||
|
glob.server.start()
|
||
|
|
||
|
# Terminal loop
|
||
|
while True:
|
||
|
try:
|
||
|
cmd = input("> ")
|
||
|
if cmd == "quit" or cmd == "exit" or cmd == "stop":
|
||
|
exit(0)
|
||
|
else:
|
||
|
print("> Restarting...")
|
||
|
client.restart()
|
||
|
"""for module in sys.modules.values():
|
||
|
reload(module)
|
||
|
glob.server = Server(glob.config["host"], glob.config["port"])
|
||
|
glob.server.start()"""
|
||
|
except Exception as e:
|
||
|
print(e)
|