-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverLauncher.py
More file actions
62 lines (51 loc) · 1.55 KB
/
serverLauncher.py
File metadata and controls
62 lines (51 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import subprocess
import sys
import os
import logging
def main():
logging.basicConfig(
# filename="project.log",
# filemode="w",
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
handlers=[
logging.FileHandler("project.log", mode="w"),
logging.StreamHandler(sys.stdout)
]
)
logging.info("starting server...")
http_server = subprocess.Popen(
[sys.executable, "-m", "http.server"],
cwd=os.getcwd(),
# stdout=subprocess.PIPE,
# stderr=subprocess.STDOUT,
stdout=sys.stdout,
stderr=sys.stderr,
text=True
)
flask_server = subprocess.Popen(
[sys.executable, "appflask.py"],
cwd=os.getcwd(),
# stdout=subprocess.PIPE,
# stderr=subprocess.STDOUT,
stdout=sys.stdout,
stderr=sys.stderr,
text=True
)
# try:
# while True:
# http_line = http_server.stdout.readline()
# flask_line = flask_server.stdout.readline()
# if http_line:
# logging.info("[http.server] %s", http_line.strip())
# if flask_line:
# logging.info("[Flask] %s", flask_line.strip())
# if http_server.poll() is not None and flask_server.poll() is not None:
# break
# except KeyboardInterrupt:
# logging.info("Interruption ...")
# http_server.terminate()
# flask_server.terminate()
# logging.info("Servers stopped.")
if __name__ == "__main__":
main()