Skip to content

Commit d21a293

Browse files
tridgeclaude
andcommitted
systemd: fix unit file warnings + start_webadmin PATH + migrate bug
Three issues caught while migrating FireVPS: * systemd[1]: "Unknown key 'StartLimitIntervalSec' in section [Service]" — those directives belong under [Unit], not [Service]. systemd silently ignored them and applied defaults. Move to [Unit] in both units. * supportproxy-webadmin exited 127 ("command not found") because start_webadmin.sh's `exec gunicorn ...` runs under systemd's default PATH (no ~/.local/bin), and FireVPS uses a pip-user-install for gunicorn rather than a venv. The existing `source venv/bin/ activate` line gracefully no-ops when there's no venv, but PATH was left without ~/.local/bin. Prepend it explicitly. * migrate_to_systemd.sh had `$SUDO -u "$SP_USER" tee ...` which expands to `-u fire tee ...` (i.e. tries to run `-u` as a command) when SUDO is empty because we're already root. Write the file with $SUDO tee and chown it to the daemon user afterwards. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5ad3cb3 commit d21a293

4 files changed

Lines changed: 20 additions & 10 deletions

File tree

scripts/migrate_to_systemd.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ WUI=$DATA/webui.json
193193
if [ -f "$WUI" ]; then
194194
$SUDO cp -p "$WUI" "$WUI.bak.$(date +%Y%m%d-%H%M%S)"
195195
fi
196-
$SUDO -u "$SP_USER" tee "$WUI" >/dev/null <<JSON
196+
$SUDO tee "$WUI" >/dev/null <<JSON
197197
{
198198
"title": "SupportProxy ($SP_DOMAIN)",
199199
"mode": "standalone",
@@ -202,6 +202,11 @@ $SUDO -u "$SP_USER" tee "$WUI" >/dev/null <<JSON
202202
"behind_proxy": true
203203
}
204204
JSON
205+
# Make sure the file is owned by the daemon user — `$SUDO tee` writes
206+
# as root, but the running supportproxy daemon reads as $SP_USER and
207+
# never writes here, so 0644 + chown is fine.
208+
$SUDO chown "$SP_USER:$SP_USER" "$WUI"
209+
$SUDO chmod 644 "$WUI"
205210

206211
# ----- 8. systemd units ----------------------------------------------
207212
echo

start_webadmin.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ export WEBADMIN_SECRET_KEY="$(cat .webadmin_secret)"
3636
export WEBADMIN_KEYDB_PATH="$(pwd)/keys.tdb"
3737
export PYTHONPATH="$HOME/SupportProxy"
3838

39+
# Prepend ~/.local/bin for pip user-install gunicorn (the README's
40+
# alternative to a venv). systemd's default PATH doesn't include it,
41+
# so without this exec gunicorn would exit 127.
42+
export PATH="$HOME/.local/bin:$PATH"
43+
3944
gunicorn_args=( -w 1 -k gthread --threads 4
4045
--timeout 60 --graceful-timeout 30
4146
-b "$webui_host:$webui_port" )

systemd/supportproxy-webadmin.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Description=SupportProxy web admin UI (gunicorn)
33
Documentation=https://github.com/ArduPilot/SupportProxy
44
After=network-online.target supportproxy.service
55
Wants=network-online.target
6+
StartLimitIntervalSec=60
7+
StartLimitBurst=5
68

79
[Service]
810
Type=simple
@@ -19,8 +21,6 @@ ExecStart=/home/support/SupportProxy/start_webadmin.sh
1921
# someone running `pkill -f webadmin.wsgi:application` by hand.
2022
Restart=always
2123
RestartSec=5s
22-
StartLimitIntervalSec=60
23-
StartLimitBurst=5
2424
StandardOutput=append:/home/support/proxy/webui.log
2525
StandardError=inherit
2626

systemd/supportproxy.service

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ Description=SupportProxy MAVLink proxy daemon
33
Documentation=https://github.com/ArduPilot/SupportProxy
44
After=network-online.target
55
Wants=network-online.target
6+
# Bail out of the restart loop if the binary is genuinely broken:
7+
# 5 restarts within 60 s puts the unit into failed state for an
8+
# operator to investigate (journalctl -u supportproxy will show
9+
# why). Resume with `systemctl reset-failed supportproxy &&
10+
# systemctl start supportproxy` once fixed.
11+
StartLimitIntervalSec=60
12+
StartLimitBurst=5
613

714
[Service]
815
Type=simple
@@ -16,13 +23,6 @@ ExecStart=/home/support/SupportProxy/supportproxy
1623
# an accidental external pkill.
1724
Restart=always
1825
RestartSec=5s
19-
# Bail out of the restart loop if the binary is genuinely broken:
20-
# 5 restarts within 60 s puts the unit into failed state for an
21-
# operator to investigate (journalctl -u supportproxy will show
22-
# why). Resume with `systemctl reset-failed supportproxy &&
23-
# systemctl start supportproxy` once fixed.
24-
StartLimitIntervalSec=60
25-
StartLimitBurst=5
2626
# The daemon's printf output is the activity log; mirror it to the
2727
# legacy proxy.log path so existing tail-and-grep habits still work.
2828
# Append-mode is safe across restarts; systemd opens the file each

0 commit comments

Comments
 (0)