-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstartWebServer.py
More file actions
55 lines (41 loc) · 1.77 KB
/
Copy pathstartWebServer.py
File metadata and controls
55 lines (41 loc) · 1.77 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
__author__ = 'henla464'
import logging, logging.handlers
from init import *
import os
from battery import Battery
from daemonize import Daemonize
from webroutes import api
def startWebServer():
logging.info("startWebServer() Start web server")
Battery.Setup()
app.run(debug=True, host='0.0.0.0', use_reloader=False)
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
filename='WiRocWS.log',
filemode='w')
# set a format which is simpler for console use
formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
rotFileHandler = logging.handlers.RotatingFileHandler('WiRocWS.log', maxBytes=20000000, backupCount=3)
rotFileHandler.setFormatter(formatter)
# define a Handler which writes INFO messages or higher to the sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.INFO)
console.setFormatter(formatter)
# add the handler to the root logger
logging.getLogger('').addHandler(rotFileHandler)
logging.getLogger('').addHandler(console)
startWebServer()
#keep_fds = [rotFileHandler.stream.fileno()]
#wd = os.getcwd()
#logging.info("before daemonize")
#pidfile = "/var/run/WiRocPythonWS.pid"
#daemon = Daemonize(app="WiRocPythonWS",
# pid=pidfile,
# logger=logging.getLogger(''),
# foreground=False,
# action=startWebServer,
# #chdir="/home/chip/WiRoc-Python-2",
# chdir=wd, #"/home/henla464/Documents/WiRoc/WiRoc-Python-2"
# keep_fds=keep_fds)
#daemon.start()