Skip to content

fix: Force Connect's service log to stdout at INFO level - #74

Merged
nealrichardson merged 1 commit into
mainfrom
service-log-stdout
Oct 23, 2026
Merged

nealrichardson merged 1 commit into
mainfrom
service-log-stdout

Conversation

@nealrichardson

Copy link
Copy Markdown
Collaborator

Fixes #40.

Problem

with-connect tells that Connect has started by reading the container's output for Starting HTTP server on. That message is an INFO-level line in Connect's service log. If a --config file sends [Logging] ServiceLog to a file, or sets ServiceLogLevel to WARN or ERROR, the message never reaches the container output and with-connect fails with "Posit Connect did not log HTTP server start within 60 seconds."

Fix

The container environment includes CONNECT_LOGGING_SERVICELOG=STDOUT and CONNECT_LOGGING_SERVICELOGLEVEL=INFO. Connect gives CONNECT_* environment variables precedence over the config file. The env setup moved into a small build_container_env() helper so it can be tested directly; user -e vars are still applied last, so they can override these defaults.

ServiceLogFormat = JSON does not need handling: the JSON lines still contain Starting HTTP server on [::]:3939 and Starting Posit Connect v..., so the existing substring checks match.

README documents the forced settings next to the CONNECT_ env var paragraph.

Verification with real containers

Used README.md as a stand-in license: Connect starts and logs, then with-connect stops at the license check, which comes after the point where the HTTP server line is logged.

Image Config Without fix With fix
ghcr.io/posit-dev/connect:latest (2026.10.0) ServiceLog = <file> "did not log HTTP server start within 60 seconds", only "Using file ... to store Server Logs." in output Starting HTTP server on [::]:3939 logged, fails on license as expected
ghcr.io/posit-dev/connect:latest ServiceLogLevel = WARN No Starting HTTP server line in output (only the license warning, so a valid license would time out) — (covered by the combined config below)
ghcr.io/posit-dev/connect:latest ServiceLogFormat = JSON {"level":"info","msg":"Starting HTTP server on [::]:3939",...} matches —
ghcr.io/posit-dev/connect:latest file + JSON + WARN — JSON Starting HTTP server on line logged
rstudio/rstudio-connect:jammy-2025.10.0 file + JSON + WARN — JSON Starting HTTP server on line logged
ghcr.io/posit-dev/connect:latest JSON config, -e CONNECT_LOGGING_SERVICELOG=/tmp/x.log — User override wins: "Using file /tmp/x.log", times out as expected

A side note from testing: a --config file replaces the image's default rstudio-connect.gcfg entirely, so it also has to set [HTTP] Listen = :3939 (otherwise Connect exits with "No server listeners are configured"). That's outside this fix.

Tests

  • test_container_env_forces_service_log_to_stdout: the bootstrap and logging defaults are present.
  • test_container_env_user_vars_override_defaults: -e values override the defaults, values containing = are kept, and entries without = are ignored.

Both are registered in the __main__ block. uv run test_main.py and pytest pass.

Merge conflicts with open PRs

git merge-tree against fix-command-errors (#69), clean-errors (#70), and fast-stop (#71) reports no conflicts. There was no #72 or auto-port branch to check.

🤖 Generated with Claude Code

with-connect detects startup by reading "Starting HTTP server on" from
the container's output. A --config file that sends ServiceLog to a file,
or sets ServiceLogLevel above INFO, hides that message and with-connect
times out. Set CONNECT_LOGGING_SERVICELOG=STDOUT and
CONNECT_LOGGING_SERVICELOGLEVEL=INFO in the container environment, which
take precedence over the config file. User -e vars still override them.

Fixes #40.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nealrichardson
nealrichardson merged commit 10cd42c into main Oct 23, 2026
13 checks passed
@nealrichardson
nealrichardson deleted the service-log-stdout branch October 23, 2026 16:32
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.

Need to set ServiceLog to STDOUT

1 participant