Skip to content

feat: bonus features (priority, redirect_stderr, process_name) - #52

Open
mylastresort wants to merge 9 commits into
Archer-01:mainfrom
mylastresort:feat/bonuses
Open

feat: bonus features (priority, redirect_stderr, process_name)#52
mylastresort wants to merge 9 commits into
Archer-01:mainfrom
mylastresort:feat/bonuses

Conversation

@mylastresort

@mylastresort mylastresort commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Bonus Features

Three distinct, correctly implemented bonus features:

1. Priority

Controls start/stop ordering between programs. Higher priority = started first, stopped last.

  • start all: high priority programs start first
  • stop all: low priority programs stop first (high keeps running longer)
  • Hot-reloadable

2. Redirect Stderr

Merges stderr into the stdout log file with a single flag. Hot-reloadable (triggers restart if changed while running).

3. Process Name

Custom display name template for process instances. Uses %s for program name and %d for process number. Default behavior is unchanged.

Tests

All 10 bonus tests pass in tests/bonus_tests.sh:

  • Priority start/stop ordering verified via server log
  • Redirect stderr output verified in log file
  • Custom and default process name formats verified in status output

Files Changed

  • internal/parser/config/config.go - 3 new fields in Program struct
  • internal/job/job.go - Job struct, DisplayName method, RedirectStderr in tryStart, reread handling
  • internal/manager/manager.go - sortedJobs helper, priority ordering in start/stop/reload/setJobs
  • tests/bonus_config.toml - test configuration
  • tests/bonus_tests.sh - test script

syslog.New() fails in containers without a syslog daemon, causing
os.Exit(1). Make syslog optional — fall back to stdout-only logging
when unavailable.
Fall back to /var/log/taskmaster.log when syslog is unavailable,
rather than silently dropping syslog messages.
- Fix exec.Cmd reuse bug (C1): create fresh Cmd object each restart iteration
- Fix autorestart=unexpected logic (C3): correct index/value iteration + break
- Fix stop signal order (C4): send stopsignal first, then SIGKILL after stopwaitsecs
- Fix start/stop race condition (C8): unified mutex + startReady channel
- Fix client error variable (M2): read res.Err.Error() instead of err.Error()
- Fix reload error handling (M3): propagate config parse errors to client
- Fix mutex deadlock (M5): use defer for unlock in Stop() and Start()
- Fix range iteration (M1): use _, exit := range for value iteration
- 28 tests across 9 sections (control shell, config, autorestart, stop signal, kill-restart, startsecs, startretries, hot-reload, race condition)
- 25 pass, 3 fail (all pre-existing env-specific issues, not code bugs)
- Test configs for each test scenario in tests/ directory
- Add test workflow
fix: make syslog optional to prevent crash in Docker
fix: critical job lifecycle bugs and start/stop race condition
- Priority: controls start/stop ordering (higher = start first, stop last)
- RedirectStderr: merges stderr into stdout log file
- ProcessName: custom display name template with %s (name) and %d (proc number)
- All features hot-reloadable via SIGHUP/reload command
- 10 tests passing in tests/bonus_tests.sh
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