Stop the old sms-inbound instance before a fresh reinstall, not after
The port-taken message on the last run ("Port 8093 was taken — the relay
will use 8094") was this service colliding with itself, not a real
conflict. Fresh-install never stopped the previous run before scanning
for a free port, so it always found its own earlier process still bound
to 8093, silently moved to 8094, and then `systemctl enable --now` was a
no-op against an already-active unit -- meaning the OLD process (holding
the OLD AMI secret and OLD relay token, from before this session's
settings.env fix) kept serving traffic while the freshly-written config
and port sat unused underneath it.
Fix: `systemctl stop sms-inbound` right before the port scan. Now the
scan only reports a real conflict from something else, and the box
should settle back on 8093 (or whatever's actually free) with the
process that's really running matching what was just configured.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JDyKC6Kdg7tofmYSmRtgww
This commit is contained in:
+10
-1
@@ -732,12 +732,21 @@ install_sms-inbound() {
|
||||
|
||||
# ── Relay service ─────────────────────────────────────────────────────────
|
||||
mkdir -p "$SMS_APP_DIR"
|
||||
# Stop any instance of this exact service BEFORE scanning for a free
|
||||
# port. Otherwise a fresh install run while the service is still up
|
||||
# from a previous run always finds its own old process squatting on
|
||||
# 8093, "frees" itself onto 8094 instead, and `enable --now` below is
|
||||
# then a no-op against an already-active unit — leaving the OLD
|
||||
# process (old token, old AMI secret) as the one actually serving
|
||||
# traffic while the newly-written config sits unused. Confirmed live:
|
||||
# exactly this sequence on a re-run right after a fresh install.
|
||||
systemctl stop sms-inbound 2>/dev/null || true
|
||||
local RELAY_PORT=8093
|
||||
local _limit=$((RELAY_PORT + 100))
|
||||
while ss -tlnH "sport = :${RELAY_PORT}" 2>/dev/null | grep -q . && [[ "$RELAY_PORT" -lt "$_limit" ]]; do
|
||||
RELAY_PORT=$((RELAY_PORT + 1))
|
||||
done
|
||||
[[ "$RELAY_PORT" != 8093 ]] && log_info "Port 8093 was taken — the relay will use ${RELAY_PORT}."
|
||||
[[ "$RELAY_PORT" != 8093 ]] && log_info "Port 8093 was taken by something else — the relay will use ${RELAY_PORT}."
|
||||
|
||||
local RELAY_TOKEN
|
||||
RELAY_TOKEN="$(generate_password 32)"
|
||||
|
||||
Reference in New Issue
Block a user