Investigations

Job Scheduler System

Go December 2024

A distributed Go job scheduling system with channel-based processing, external app execution, and a REST API.

This started as an investigation into Go's concurrency primitives — specifically, how far you can push channels and goroutines before you need to reach for something heavier. The answer: pretty far.

The scheduler processes jobs through named channels, each with configurable worker pools. Submit a job to a channel and one of its workers picks it up, executes it (potentially launching an external application), and reports the result. The system handles timeouts, captures output up to a configurable limit, and tracks per-channel statistics: active jobs, total jobs, failures.

The REST API layer sits on top with endpoints for submitting jobs, checking status by job ID, and getting channel statistics. There's HTTP middleware for CORS and auth, plus static file serving for the JavaScript frontend.

What I found most interesting was the graceful shutdown implementation. When you signal the system to stop, it needs to let running jobs finish, prevent new jobs from starting, drain the channels, and close the HTTP server — all without deadlocking. Getting the ordering right with Go's sync primitives was a satisfying puzzle.

What this project demonstrates

Channel-based job processing with configurable worker pools
External application execution with env, args, and timeout support
REST API: job submission, status monitoring, channel stats
Graceful shutdown without deadlocks
Configurable queue sizes and output capture limits
HTTP middleware for CORS and authentication

Technologies

ConcurrencyREST APIJob SchedulerChannels

© 2026 Jonathan Leahy · v0.8.3