Skip to content

Add optional launch_cmd to auto-start Ardop/VARA/AGWPE TNC daemons - #544

Open
mwthomson wants to merge 4 commits into
la5nta:developfrom
mwthomson:develop
Open

Add optional launch_cmd to auto-start Ardop/VARA/AGWPE TNC daemons#544
mwthomson wants to merge 4 commits into
la5nta:developfrom
mwthomson:develop

Conversation

@mwthomson

Copy link
Copy Markdown

Addresses #537.

Adds an optional launch_cmd setting to Pat's config for the four transports that depend on an external TNC daemon: Ardop, VaraHF, VaraFM, and AX.25/AGWPE. When set, Pat spawns that daemon itself the first time the transport is used, instead of requiring the user to start it by hand first.

"ardop": {
  "addr": "localhost:8515",
  "launch_cmd": {"path": "ardopcf", "args": ["--webgui", "8514"]}
}

Behavior, consistent across all four transports:

  • Skips the launch if the daemon is already reachable (no duplicate spawns, even under concurrent connect/listen).
  • On outgoing connect, waits up to 5s (polling every 500ms) for a freshly-launched daemon to come up before giving up.
  • On incoming listen, relies on the existing ListenerHub retry loop rather than blocking.
  • Relaunches automatically if the daemon crashes or is killed mid-session.
  • Terminates any process it spawned when Pat itself exits (App.Close()) — no orphaned daemons.
  • Logs a terse Pat failed to launch <transport> on failure; full error only at debug level.
  • Strictly opt-in — leaving launch_cmd unset is a complete no-op, existing behavior unchanged.

This directly solves the underlying need in #537 (bringing up ardopcf's webgui alongside Pat) without Pat embedding or knowing anything about that UI — it just launches whatever command is configured.

Test plan

  • go build ./..., go vet ./... clean
  • go test ./... passes
  • Unit tests cover: skip-when-reachable, launch-then-connect within poll budget, launch failure (bad path / never reachable) with exact log message, no duplicate spawn under concurrent Connect+Listen (-race), relaunch after crash, App.Close() terminates spawned processes
  • Manually tested against a running AGWPE/Direwolf setup

Lets Pat spawn the Ardop, VaraHF, VaraFM, and AX.25/AGWPE transports'
backing TNC daemon itself (e.g. ardopcf --webgui 8514, or Direwolf)
the first time the transport is used, instead of requiring it to
already be running. Launch is skipped when already reachable, retried
with a bounded poll on the outgoing connect path, relaunched if the
daemon drops out later in the same run, and terminated on Pat exit.

Addresses la5nta#537.
Ardop never got the IsZero/IsZeroExceptLaunchCmd default-Addr rescue
that AGWPE and VaraHF/VaraFM already have, so a config setting only
ardop.launch_cmd (no addr) launches ardopcf successfully but then
fails every dial against the never-backfilled empty address.

VaraConfig.UnmarshalJSON's port-validation guard had also narrowed to
just checking Addr != "", silently accepting a config that sets e.g.
rig/ptt_ctrl but no addr instead of failing fast at load time.

Fixes la5nta#548
Fixes la5nta#549
…b UI

Exposes the launch_cmd (path/args) config already supported by the
backend for these four transports, using the same tokenfield widget
already used for auxiliary_addresses to represent the args list.

Closes la5nta#547
@mwthomson
mwthomson marked this pull request as draft August 27, 2026 23:25
The new comments across app/connect.go, cfg/config.go, and app/config.go
had drifted into multi-paragraph rationale blocks, much of it repeated
near-verbatim across the Ardop/VaraHF-VaraFM/AGWPE variants. Condensed
back down to the one-or-two-line doc comments used everywhere else in
these files, keeping only the genuinely non-obvious why.
@mwthomson
mwthomson marked this pull request as ready for review August 27, 2026 23:59
@mwthomson

Copy link
Copy Markdown
Author

General cleanup and fixes for #547, #548, and #549 now rolled into this PR. Ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant