forked from Wolfenswan/FAMDB
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstartServer.py
More file actions
executable file
·33 lines (27 loc) · 797 Bytes
/
Copy pathstartServer.py
File metadata and controls
executable file
·33 lines (27 loc) · 797 Bytes
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
import os
import sys
from pathlib import Path
from wsgiref.simple_server import make_server
import utils
import wsgi
from handleDbStart import initDb
initDb()
print('starting server...')
# Server settings
path = Path("famdb.pid")
if path.exists():
file = open("famdb.pid", "r")
pid = int(list(file)[0])
serverRunning = utils.isPidRunning(pid)
if serverRunning:
print('Fatal:Detecting server already running as pid:' + str(pid) + "\nPlease kill this first",
file=sys.stderr)
exit()
else:
print('Warning:PID file detected, but no running process found, continuing')
file = open("famdb.pid", "w+")
file.write(str(os.getpid()))
file.close()
print('running server...')
httpd = make_server('', utils.port, wsgi.wsgi)
httpd.serve_forever()