feat(service): cmd.service takes a status action - #6
Merged
Merged
Conversation
Reading one service's state meant waiting for the next service_check
telemetry. `{"action":"status","service_name":"nginx"}` now answers on
demand, with `service_status` in the telemetry's words (Running,
Stopped, NotInstalled, ...) beside the usual human-readable `result`.
QueryService goes through GetServiceStatuses, the call the telemetry
already makes on every platform, so the command and the telemetry
cannot describe a service differently and no platform code is new. It
uses the same allowed_services gate as start, stop and restart. A
service that does not exist answers NotInstalled, as in telemetry.
Also corrects the architecture doc's example reply, which showed an
`output` field cmd.service has never sent.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cmd.servicegains astatusaction, so you can read one service's state on demand. Before, the only way to see it was to wait for the nextservice_checktelemetry.{"status":"success","service_name":"nginx","action":"status", "result":"Service nginx is Running","service_status":"Running","ts":"..."}Design
QueryServicecallsGetServiceStatuses, the function theservice_checktelemetry already uses on every platform. The command and the telemetry can't describe the same service differently, and there's no new per-platform code.allowed_services, the same as start, stop and restart.service_statususes the telemetry's values:Running,Stopped,Starting,Stopping,Error,UnknownorNotInstalled.NotInstalled, as it does in telemetry.service_statusis absent for start, stop and restart, and the reply is otherwise the same shape as before.Testing
systemd-journaldreportsRunning, and a made-up service reportsNotInstalled. The test skips on machines without systemd.go test -race ./...passesgo vetis clean on Linux, Windows, FreeBSD and darwinKnown limit
On Windows,
statusconnects to the service manager the same way the telemetry does. That works when the agent runs as a service. From a non-admin shell it answers "Access is denied", just as the telemetry would.Also
Fixes the example reply in
docs/architecture.md's service diagram. It showed anoutputfield thatcmd.servicehas never sent; the field isresult.🤖 Generated with Claude Code