initial commit:
This commit is contained in:
46
app.py
Normal file
46
app.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import subprocess
|
||||
import atexit
|
||||
import sys
|
||||
import time
|
||||
|
||||
trackedProcesses : list = []
|
||||
|
||||
def cleanup():
|
||||
print("\n[MainServer] Cleaning up server processes")
|
||||
for proc in trackedProcesses:
|
||||
if proc.poll() is None:
|
||||
print(f"[MainServer] Terming server subroutine {proc.pid}")
|
||||
proc.terminate()
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
for proc in trackedProcesses:
|
||||
if proc.poll() is None:
|
||||
print(f"[MainServer] Forcekilling leftover process {proc.pid}")
|
||||
proc.kill()
|
||||
|
||||
atexit.register(cleanup)
|
||||
|
||||
def main():
|
||||
try:
|
||||
ns = subprocess.Popen([sys.executable, 'nameserver.py'])
|
||||
trackedProcesses.append(ns)
|
||||
api =subprocess.Popen([sys.executable, 'api.py'])
|
||||
trackedProcesses.append(api)
|
||||
auth =subprocess.Popen([sys.executable, 'auth.py'])
|
||||
trackedProcesses.append(auth)
|
||||
cdn =subprocess.Popen([sys.executable, 'cdn.py'])
|
||||
trackedProcesses.append(cdn)
|
||||
|
||||
while True:
|
||||
# make it run forever without doing anything (it should still output the individual servers outputs)
|
||||
pass
|
||||
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\n[MainServer] Server closing!")
|
||||
finally:
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user