From 7e9e815bf6cc17dfde681f76305cf8a7417f9059 Mon Sep 17 00:00:00 2001 From: Roland Date: Thu, 18 Dec 2025 17:51:18 -0700 Subject: [PATCH] Creating wrolpi-api-dev service to run api in debug mode. --- controller/defaults.py | 9 +++++++++ etc/raspberrypios/wrolpi-api-dev.service | 19 +++++++++++++++++++ etc/raspberrypios/wrolpi-api.service | 3 ++- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 etc/raspberrypios/wrolpi-api-dev.service diff --git a/controller/defaults.py b/controller/defaults.py index 901d36f0..9ced9c46 100644 --- a/controller/defaults.py +++ b/controller/defaults.py @@ -33,6 +33,15 @@ DEFAULT_CONFIG = { "use_https": False, "description": "Python API (Sanic)", }, + { + "name": "wrolpi-api-dev", + "systemd_name": "wrolpi-api-dev", + "port": 8081, + "viewable": True, + "use_https": False, + "description": "Python API (Development)", + "show_only_when_running": True, + }, { "name": "wrolpi-app", "systemd_name": "wrolpi-app", diff --git a/etc/raspberrypios/wrolpi-api-dev.service b/etc/raspberrypios/wrolpi-api-dev.service new file mode 100644 index 00000000..657bdb2f --- /dev/null +++ b/etc/raspberrypios/wrolpi-api-dev.service @@ -0,0 +1,19 @@ +[Unit] +Description=WROLPi Python API (Development) +Wants=postgresql.service +PartOf=wrolpi.target +Conflicts=wrolpi-api.service + +[Service] +Environment=PYTHONUNBUFFERED=1 +ExecStart=/opt/wrolpi/venv/bin/python -m sanic main:api_app --host 0.0.0.0 --port 8081 -w 1 --reload --debug +ExecReload=/bin/kill -HUP $MAINPID +Group=wrolpi +User=wrolpi +WorkingDirectory=/opt/wrolpi/ +Restart=on-failure +# Higher than the App so the API can start. +Nice=4 + +[Install] +WantedBy=default.target diff --git a/etc/raspberrypios/wrolpi-api.service b/etc/raspberrypios/wrolpi-api.service index 4cae7c2f..9b06c760 100644 --- a/etc/raspberrypios/wrolpi-api.service +++ b/etc/raspberrypios/wrolpi-api.service @@ -2,10 +2,11 @@ Description=WROLPi Python API Wants=postgresql.service PartOf=wrolpi.target +Conflicts=wrolpi-api-dev.service [Service] Environment=PYTHONUNBUFFERED=1 -ExecStart=/opt/wrolpi/venv/bin/sanic main:api_app --host 0.0.0.0 --port 8081 -w 5 +ExecStart=/opt/wrolpi/venv/bin/python -O -m sanic main:api_app --host 0.0.0.0 --port 8081 -w 5 ExecReload=/bin/kill -HUP $MAINPID Group=wrolpi User=wrolpi