')
- print('')
- print(' ')
- print('')
- sys.stdout.flush()
-
-def htmlize(s):
- s = s.replace("&", "&")
- s = s.replace("<", "<")
- s = s.replace(">", ">")
- s = s.replace("\n", " ")
- return s
def notify_launcher(str):
# Create a socket (SOCK_STREAM means a TCP socket)
@@ -56,6 +22,13 @@ def notify_launcher(str):
finally:
sock.close()
+def htmlize(s):
+ s = s.replace("&", "&")
+ s = s.replace("<", "<")
+ s = s.replace(">", ">")
+ s = s.replace("\n", " ")
+ return s
+
@asyncio.coroutine
def handler(websocket, path):
with open(FILE, 'r') as fin:
@@ -69,32 +42,27 @@ def handler(websocket, path):
asyncio.get_event_loop().stop()
-
if os.fork():
sys.exit(0)
-os.setsid()
+time.sleep(1)
-if os.fork():
- # request log file creation from launcher
- notify_launcher("logging-start")
+os.setsid()
- # this is the server process which reads the file, monitors
- # it for new contents and forwards it to the client
- loop = asyncio.get_event_loop()
- start_server = websockets.serve(handler, "", 9001)
- websocket_server = loop.run_until_complete(start_server)
+# request log file creation from launcher
+notify_launcher("logging-start")
- try:
- loop.run_forever()
- finally:
- websocket_server.close()
- loop.run_until_complete(websocket_server.wait_closed())
+# this is the server process which reads the file, monitors
+# it for new contents and forwards it to the client
+loop = asyncio.get_event_loop()
+start_server = websockets.serve(handler, "", 8999)
+websocket_server = loop.run_until_complete(start_server)
- notify_launcher("logging-stop")
- sys.exit(0)
+try:
+ loop.run_forever()
+finally:
+ websocket_server.close()
+ loop.run_until_complete(websocket_server.wait_closed())
-# some delay to make sure the server is listening
-time.sleep(2)
-dump_html()
+notify_launcher("logging-stop")