.NET 8 Job Control Daemon
Taskmaster is a lightweight process supervisor inspired by Supervisor. It launches, monitors, and manages multiple programs defined in YAML, with support for automatic restarts, configurable policies, and multiple control interfaces.
- Features
- Architecture
- Installation
- Configuration
- Usage
- Building & Running
- Demo Script
- Evaluation Tips
- License
- YAML-based program definitions
- Automatic process supervision with restart policies (
always,never,unexpected) - Configurable options:
cmd,numprocs,autostart,exitcodes,starttime,startretries,stopsignal,stoptime, stdout/stderr redirection, environment vars, workingdir, umask - Multiple control interfaces:
- Interactive shell with history and editing
- TCP control server on
127.0.0.1:9090 - HTTP/JSON API on
http://localhost:8080/api
- Graceful reload and shutdown via signals or commands
- Cross-platform support (Windows/Unix)
- Logging to file and colored console output
- ConfigurationManager: loads and validates
taskmaster.yaml. - TaskmasterDaemon: orchestrates startup, signal handlers, monitoring loop, and control servers.
- ProcessManager: spawns and tracks
ProcessInfoinstances, enforces restart/back-off logic. - CommandShell: REPL with advanced
ReadLineWithHistory(). - Control Servers: TCP on port 9090 and HTTP API on port 8080.
Clone the repository:
git clone https://github.com/youruser/taskmaster.git
cd taskmasterEdit taskmaster.yaml to define your programs:
programs:
webapp:
cmd: "dotnet run --project WebApp"
numprocs: 2
autostart: true
autorestart: unexpected
exitcodes: [0]
starttime: 5
startretries: 3
stopsignal: TERM
stoptime: 10
stdout: logs/webapp.stdout
stderr: logs/webapp.stderr
env:
ASPNETCORE_ENVIRONMENT: Production
CONNECTION_STRING: "Server=..."dotnet run -- -c taskmaster.yaml
taskmaster> status
taskmaster> start webapp
taskmaster> reload
taskmaster> shutdownUse arrow keys for command history and editing.
telnet 127.0.0.1 9090
> status
> start webapp
> exit# Get status JSON
curl http://localhost:8080/api/status
# Control a program
curl -X POST http://localhost:8080/api/programs/webapp/start
# Reload configuration
curl -X POST http://localhost:8080/api/reload
# Shutdown daemon
curl -X POST http://localhost:8080/api/shutdownBuild in Release mode:
dotnet build -c ReleaseRun with custom config:
dotnet run -- -c path/to/taskmaster.yamlRun in background (daemon) mode:
dotnet run -- -d-
Launch Taskmaster
dotnet run -- -c taskmaster.yaml
- In the shell, confirm autostarted programs:
taskmaster> status
- In the shell, confirm autostarted programs:
-
Simulate a Failure & Observe Restart
- In another terminal, note a running PID:
taskmaster> status - Kill that process:
# Unix kill <pid> # Windows taskkill /PID <pid> /F
- Back in Taskmaster shell, verify automatic restart:
taskmaster> status
- In another terminal, note a running PID:
-
Interactive Shell Tasks
taskmaster> stop webapp taskmaster> start webapp taskmaster> restart worker
-
TCP Control Interface
telnet 127.0.0.1 9090
Inside the session:
> status > stop webapp > start webapp > exit -
HTTP/JSON API Calls
# Get full status curl http://localhost:8080/api/status # Restart a program curl -X POST --data "" http://localhost:8080/api/programs/simple-web/restart
-
Reload Configuration Without Downtime
- Edit
taskmaster.yaml(e.g. changeworker.numprocsfrom 1 to 2). - Save the file.
- Trigger reload in shell or via HTTP:
taskmaster> reload # or curl -X POST http://localhost:8080/api/reload
- Confirm new instances:
taskmaster> status
- Edit
-
Signal Handling
- Reload via SIGHUP (Unix):
kill -HUP <daemon_pid>
- Dump status via SIGUSR1:
kill -USR1 <daemon_pid>
- Check the log file for the status dump entry.
- Reload via SIGHUP (Unix):
-
Graceful Shutdown
- From the shell:
taskmaster> shutdown - Or send Ctrl+C in the console, or via HTTP:
curl -X POST http://localhost:8080/api/shutdown
- From the shell:
- Slides: diagram flow (Config → Daemon → ProcessManager → Interfaces).
- Key code walkthrough:
Program.cs,TaskmasterDaemon.cs,ProcessManager.cs,CommandShell.cs. - Live demo: follow the Demo Script above.
- Be prepared to discuss restart logic, back-off, non-disruptive reload, and cross-platform signal handling.