From 99cd3768e40cb7b1c07a277156e0ecc73d5ce971 Mon Sep 17 00:00:00 2001 From: arne Date: Tue, 31 Jan 2023 20:57:07 +0100 Subject: [PATCH] add logger --- app.py | 9 +++++++-- entrypoint.sh | 2 +- webapp.initrc | 12 ++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app.py b/app.py index a23088d..77d855d 100644 --- a/app.py +++ b/app.py @@ -1,10 +1,16 @@ import asyncio -import websockets import json +import logging +import websockets clients = {} vars = {} +logging.basicConfig( + format="%(asctime)s %(message)s", + level=logging.INFO, +) + async def handshake(ws,data): project_id = data.get('project_id','') user = data.get('user') @@ -31,7 +37,6 @@ async def set_variable(project_id,var): async def disconnect(project_id,ws): print(f"disconnecting {ws.host}:{ws.port}") clients.get(project_id,[]).remove(ws) - async def handler(ws, path): project_id = "" diff --git a/entrypoint.sh b/entrypoint.sh index 3cc17a1..5aab7ec 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,5 +5,5 @@ cd $BASE git pull python3 -m venv env source env/bin/activate -pip3 install -r requirements.txt +pip3 install -U -r requirements.txt python3 app.py \ No newline at end of file diff --git a/webapp.initrc b/webapp.initrc index e43f249..37662cf 100755 --- a/webapp.initrc +++ b/webapp.initrc @@ -1,12 +1,12 @@ #!/sbin/openrc-run -name="busybox $SVCNAME" -command="/opt/webapp/app.sh" -command_args="" +name="$SVCNAME" +command="/data/entrypoint.sh" pidfile="/var/run/$SVCNAME.pid" +command_background="yes" +output_logger="/usr/bin/logger" depend() { need net - use dns -} - + need dns +} \ No newline at end of file