From d6194534f55f9a305f9d89f019225468b8060d7f Mon Sep 17 00:00:00 2001 From: Matthew Frost Date: Fri, 2 Feb 2024 12:34:50 +0100 Subject: [PATCH] systemd service --- powerbar.service | 19 +++++++++++++++++++ telnet.py | 14 -------------- 2 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 powerbar.service delete mode 100644 telnet.py diff --git a/powerbar.service b/powerbar.service new file mode 100644 index 0000000..8259146 --- /dev/null +++ b/powerbar.service @@ -0,0 +1,19 @@ +[Unit] +Description=Powerbar daemon +After=network.target + +[Service] +User=powerbar +Group=powerbar +Environment="VIRTUAL_ENV=/opt/powerbar/venv" +Environment="PATH=/opt/powerbar/venv/bin:/usr/local/bin:/usr/bin:/bin" +ExecStart=/opt/powerbar/venv/bin/gunicorn app:app \ + -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker \ + --name powerbar --workers 1 \ + --max-requests 400 --max-requests-jitter 50 \ + --log-level=info --bind=0.0.0.0:5000 +WorkingDirectory=/opt/powerbar/ti-powerbar +Restart=on-failure + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/telnet.py b/telnet.py deleted file mode 100644 index b661b80..0000000 --- a/telnet.py +++ /dev/null @@ -1,14 +0,0 @@ -import telnetlib - -def check_input_error(): - tn = telnetlib.Telnet("10.209.10.111", 2168) - tn.write("/\r\n".encode('ascii')) - for _ in range(3): - output = tn.read_until(b"Input error", timeout=3).decode('ascii') - print(output) - if "Input error" in output: - return True - return False - -result = check_input_error() -print(result)