Skip to content

feat: CLI commands, always-on Unix socket, and log file tailing#1

Merged
sylvesterdamgaard merged 18 commits intomainfrom
enable-api-add-commands
Apr 17, 2026
Merged

feat: CLI commands, always-on Unix socket, and log file tailing#1
sylvesterdamgaard merged 18 commits intomainfrom
enable-api-add-commands

Conversation

@sylvesterdamgaard
Copy link
Copy Markdown
Contributor

@sylvesterdamgaard sylvesterdamgaard commented Apr 17, 2026

Summary

  • Always-on Unix socket — daemon starts a Unix socket listener regardless of api_enabled, enabling local management (cbox-init tui, CLI commands) without exposing a TCP port
  • Full CLI command suitelist, status, start, stop, restart, scale, reload-config, and reworked logs with SSE streaming (-f flag)
  • API client refactoring — extracted internal/tui/client.go to internal/apiclient/ for shared CLI/TUI use
  • SSE log streaming — new /api/v1/logs/stream endpoint + client for real-time log tailing
  • Log file tailing — new logging.files config to tail local app log files (e.g., Laravel's storage/logs/laravel.log) through the same pipeline as stdout/stderr (JSON parsing, level detection, filtering, redaction)
  • Size-based log rotation — optional rotate config per log file (max_size, max_files)

New CLI commands

cbox-init list                     # List all processes
cbox-init status nginx             # Show process details
cbox-init start horizon            # Start a process
cbox-init stop horizon             # Stop a process
cbox-init restart horizon          # Restart a process
cbox-init scale queue-default 10   # Scale to N instances
cbox-init reload-config            # Reload config from disk
cbox-init logs nginx -f            # Stream logs via SSE

Log file tailing config example

processes:
  laravel:
    command: ["php-fpm", "-F"]
    logging:
      redaction:
        enabled: true
        patterns:
          - pattern: "password=\\S+"
            replacement: "password=***"
      files:
        laravel-log:
          path: /var/www/html/storage/logs/laravel.log
          rotate:
            max_size: 50MB
            max_files: 7
          json: { enabled: true, detect_auto: true }
          min_level: info

Test plan

  • All 22 test packages pass (go test ./... -count=1)
  • New internal/logtail/ package: 11 tests (rotator + tailer)
  • New internal/apiclient/ package: 31 tests (client + SSE stream)
  • New internal/logger/subscriber_test.go: 5 broadcaster tests
  • check-config validates log file tailing config correctly
  • CLI --help shows all new commands
  • Manual test: docker exec into container, run cbox-init tui via socket
  • Manual test: cbox-init logs -f streams real-time entries

sylvesterdamgaard and others added 18 commits April 17, 2026 12:34
… use

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The daemon now always starts a Unix socket listener regardless of the
api_enabled config setting. This ensures local CLI tools and the TUI can
communicate with the daemon even when the TCP API port is not exposed.
When api_enabled is true, both TCP and socket start as before. When
api_enabled is false, only the socket listener starts (socket-only mode)
with no ACL or rate limiting since file permissions provide security.
Socket permissions changed from 0600 to 0660 to allow group access.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add `cbox-init list` to display a table of all managed processes with
state, scale, restart count, and uptime. Add `cbox-init status <name>`
for detailed single-process info including instances, resource usage,
and schedule state. Both commands use the shared apiclient with
auto-discovery of Unix sockets and --url flag override.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add process control commands that connect to the running daemon via API:
- `cbox-init start <name>` / `stop <name>` / `restart <name>`
- `cbox-init scale <name> <count>` with input validation
- `cbox-init reload-config` to hot-reload configuration

All commands share the newClient() helper from list.go, supporting
--url flag and CBOX_INIT_API_AUTH env var. Also updates root.go to
register all new commands and refresh the help examples.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add LogFileConfig and RotateConfig structs to support per-process log
file tailing configuration. Each log file gets its own pipeline config
for level detection, multiline handling, JSON parsing, and filtering.
Also adds ParseSize helper for human-readable size strings and a Files
map field to LoggingConfig.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add validation for log file path (required), rotate.max_size (ParseSize),
and rotate.max_files (non-negative). Add defaults for file-level multiline
(max_lines=100, timeout=1s), level detection (default_level=info), and
rotation (max_files=5).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wire file tailers into the Supervisor so that configured log files are
tailed when the supervisor starts and stopped on shutdown. Tailers are
config-bound (survive process restarts) and each gets a ProcessWriter
with inherited redaction config plus per-file logging settings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add specs and plans for:
- CLI commands & always-on Unix socket
- Log file tailing with rotation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sylvesterdamgaard sylvesterdamgaard merged commit f109b6e into main Apr 17, 2026
7 checks passed
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