schedularr

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README ΒΆ

Schedularr Logo

Schedularr

Content Scheduling for Tunarr

CI Go Version License PRs Welcome

Cron-based content scheduling for Tunarr TV channels, driven by rule-based blocks and content filters.

Features β€’ Quick Start β€’ Configuration β€’ Examples β€’ API β€’ Serve β€’ Docker β€’ Release Process β€’ Contributing


🎯 Overview

Schedularr generates and applies TV channel schedules for Tunarr. Scheduling rules ("blocks") define a time slot, a cron expression, a target channel, and a content filter; Schedularr resolves each block against Tunarr's library and pushes the result back to Tunarr.

What it does
  • Defines programming rules as blocks: cron expression, duration, target channel, priority.
  • Filters content by title pattern (regex), genre, rating, release year range, and duration.
  • Tracks per-show season/episode progression for series-based blocks.
  • Previews a schedule (generate, no --apply) before pushing it to Tunarr.
  • Runs as a one-shot CLI command or as a long-lived process (serve) exposing an HTTP API and a cron-driven schedule cycle.

✨ Features

Core Capabilities
Feature Description
Tunarr integration Reads channels and library content from Tunarr, pushes schedules back
Content filtering Regex title matching, genre/rating filters, year ranges, duration constraints
Cron scheduling Standard cron expressions for recurring blocks
Series blocks Sequential episode progression per show, with season/episode state persisted
HTTP API Blocks CRUD, generate/apply, history, series state, channels, status
Dry run generate without --apply previews a schedule without pushing it to Tunarr
Priority system Resolves overlapping blocks by configurable priority
Tag support Filter content by custom tags

πŸš€ Quick Start

Prerequisites
  • Go 1.27+ - Download
  • A C toolchain - the SQLite driver (mattn/go-sqlite3) is cgo-based; CGO_ENABLED=1 (the default when a C compiler is on PATH) is required to build
  • Tunarr Instance - Setup Guide
Installation
Option 1: Build from Source
# Clone the repository
git clone https://github.com/christopherime/schedularr.git
cd schedularr

# Build the binary
go build -o schedularr main.go

# Optional: Install to your PATH
sudo mv schedularr /usr/local/bin/
Option 2: Using Go Install
go install github.com/christopherime/schedularr@latest
Option 3: Docker

No local Go, Hugo, or Node needed β€” see Docker for the full build/run reference.

docker build -t schedularr:local .
Initial Setup
  1. Generate configuration files:
# Generate application config
schedularr config generate config.yaml

# Generate scheduler config
schedularr scheduler init scheduler.yaml
  1. Configure Tunarr connection:

config generate writes tunarr.url/tunarr.api_key as literal ${SCHEDULARR_TUNARR_URL}/${SCHEDULARR_TUNARR_API_KEY} placeholders (CUE-loaded config files support ${VAR} env interpolation -- see Configuration). Either export those two environment variables, or edit config.yaml directly and replace both with literal values -- an unset ${VAR} placeholder left in the file expands to an empty, unquoted YAML value, which parses as null rather than "" and fails config loading:

tunarr:
  url: "http://localhost:8000"
  api_key: ""  # quote it explicitly, even when empty
log:
  level: "info"
  format: "text"
  1. Validate your configuration:
# Validate both configs
schedularr validate config.yaml
schedularr validate scheduler.yaml
  1. Verify Tunarr connection:
schedularr --config config.yaml channels

βš™οΈ Configuration

schedularr resolves the app config file path in this order:

  1. --config <file> (global flag)
  2. SCHEDULARR_CONFIG environment variable
  3. Legacy locations, in order: ./config.yaml, ./.schedularr.yaml, ~/.config/.schedularr.yaml, ~/.schedularr.yaml
  4. ~/.schedularr/config.yaml (default)

The file is validated against the CUE schema in cmd/schema/config.cue (also embedded in the binary as internal/cueconfig). String values support ${VAR} environment variable interpolation.

Configuration Reference

Full key list, with CUE defaults:

tunarr:
  url: ""                  # Tunarr API endpoint (required)
  api_key: ""               # Optional API key
  timeout: "30s"

log:
  level: "info"              # debug, info, warn, error
  format: "text"             # text, json
  timezone: "Local"          # IANA time zone name

database: "schedularr.db"    # SQLite database path (opened with _busy_timeout=5000&_journal_mode=WAL,
                              # see internal/store/sqlite.go -- expect -shm/-wal sidecar files alongside it)
scheduler_file: "scheduler.yaml"  # First-run block import file, see below
cron_interval: "6h"          # `serve`'s cron loop cadence; `serve --interval`/`-i` overrides it

maintenance:
  history_retention: "168h"  # how long schedule_history rows are kept; also bounds
                              # GET /history?days=N -- see the History Endpoint section
  cleanup_enabled: true

api:                          # the `serve` command's HTTP server
  listen: ":8484"
  token: ""                  # bearer token for /api/v1/*; SCHEDULARR_API_TOKEN env var wins when set
  insecure_no_auth: false     # skip bearer auth entirely -- local development only

There is no metrics_port config key: schedularr serve exposes Prometheus metrics at GET /metrics on the same listener as everything else (--listen/api.listen, default :8484) -- see Serve below.

Scheduling Blocks

Blocks live in the SQLite store (database above), not in a config file. scheduler_file (default scheduler.yaml) is a first-run import format only: the first time the store is empty, its blocks are imported once; editing the file after that has no effect. Generate one with schedularr scheduler init, then either let it bootstrap on the next generate/serve run, or manage blocks going forward through the /api/v1/blocks HTTP API (see API):

blocks:
  - name: "Morning Cartoons"
    type: filter                 # required in scheduler.yaml -- see note below
    cron: "0 6 * * *"           # Daily at 6:00 AM
    duration: 240                # 4 hours (in minutes)
    channel_id: "channel-1"      # Target channel
    priority: 10                 # Higher = more important
    filter:
      genres: ["Animation", "Family"]
      max_duration: 30           # Max 30 min per show
      ratings: ["TV-Y", "TV-G"]
      year_from: 2000

  - name: "Prime Time Movies"
    type: filter
    cron: "0 20 * * *"          # Daily at 8:00 PM
    duration: 180                # 3 hours
    channel_id: "channel-1"
    priority: 20
    filter:
      genres: ["Action", "Drama"]
      min_duration: 90           # Feature-length films
      year_from: 2010
      ratings: ["PG-13", "R"]

type (filter or series) has a schema default in cmd/schema/scheduler.cue, but schedularr validate/the scheduler.yaml import path decodes each block into a Go struct before CUE-validating it, which turns an omitted type into an explicit empty string rather than an absent field -- CUE only applies the default to a genuinely absent field, so an empty string fails the "filter" | "series" check. Always set type explicitly in scheduler.yaml. POST /api/v1/blocks's JSON body does not have this problem; type there can be omitted.

Filter Options
Field Type Description Example
title_pattern string Regex pattern for title matching "^Star.*"
genres []string List of genres to include ["Comedy", "Drama"]
ratings []string Content ratings filter ["PG", "PG-13"]
year_from int Minimum release year 2000
year_to int Maximum release year 2023
min_duration int Minimum duration (minutes) 90
max_duration int Maximum duration (minutes) 120
tags []string Custom tags filter ["favorite", "classic"]

πŸ“– Usage

Command Overview
schedularr [command] [flags]

For per-command flags and a full walkthrough, see CLI Reference.

Available Commands
Command Purpose
config generate [file] Write an app config file from the CUE schema defaults (--tunarr-url, --log-level, ... override individual keys)
config dump Print the currently loaded effective config as YAML
scheduler init [file] Write a scheduler.yaml block-import file from the CUE schema defaults
validate <file> Validate an app config or scheduler.yaml file against its CUE schema (file type is inferred: a filename containing scheduler is validated as a block-import file)
channels List Tunarr channels
generate [--apply] [--yes] [--dry-run] [-v] Generate (and optionally apply) the next schedule cycle
generate config --output <file> Same config generation as config generate, under generate instead
state export/import/reset/set/list/backup Manage series progression state (internal/store)
health [--port 9600] Standalone /healthz//livez probe server (unrelated to serve's own health endpoints)
serve [--listen] [--insecure-no-auth] [--interval/-i] Run the HTTP API and the cron scheduling loop -- see Serve
List Channels
schedularr channels

Output (ID/Number/Name/Group, from a live Tunarr instance):

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ID        β”‚ NUMBER β”‚ NAME             β”‚ GROUP  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ channel-1 β”‚      1 β”‚ Classic Movies   β”‚ Movies β”‚
β”‚ channel-2 β”‚      2 β”‚ Kids Programming β”‚ Kids   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Generate Schedule

Generates a schedule from the enabled blocks in the store (bootstrapping scheduler_file into the store first, on an empty store):

# Dry run (preview only, never mutates the store or Tunarr)
schedularr generate

# Apply to Tunarr (requires --yes; there is no interactive confirmation)
schedularr generate --apply --yes

generate prints a per-channel table (start/end time, block, program, duration, type, show/season/episode) followed by a totals summary; see displaySchedule/displayChannelSchedule in cmd/generate.go.

Series State
schedularr state list                                    # table of all tracked series
schedularr state set "My Show" --season 2 --episode 5     # jump to S02E05
schedularr state reset "My Show"                          # back to S01E01
schedularr state export backup.json                       # all series states to JSON
schedularr state import backup.json                       # restore from JSON
schedularr state backup full-backup.db                    # whole-database SQLite backup (VACUUM INTO)

πŸ’‘ Examples

Example 1: Weekend Movie Marathon
blocks:
  - name: "Saturday Night Sci-Fi"
    type: filter
    cron: "0 20 * * 6"  # Saturdays at 8 PM
    duration: 360       # 6 hours
    channel_id: "channel-1"
    filter:
      genres: ["Science Fiction"]
      min_duration: 90
      year_from: 1980
Example 2: Weekday Morning Kids Block
blocks:
  - name: "Weekday Morning Cartoons"
    type: filter
    cron: "0 7 * * 1-5"  # Monday-Friday at 7 AM
    duration: 120
    channel_id: "channel-2"
    filter:
      genres: ["Animation"]
      ratings: ["TV-Y", "TV-Y7"]
      max_duration: 30
Example 3: Classic Film Noir Night
blocks:
  - name: "Film Noir Fridays"
    type: filter
    cron: "0 22 * * 5"  # Fridays at 10 PM
    duration: 240
    channel_id: "channel-1"
    filter:
      title_pattern: ".*Noir.*|.*Detective.*"
      year_from: 1940
      year_to: 1959
      genres: ["Crime", "Mystery"]
Example 4: Holiday Special Programming
blocks:
  - name: "Christmas Movies"
    type: filter
    cron: "0 18 1-25 12 *"  # Dec 1-25 at 6 PM
    duration: 180
    channel_id: "channel-1"
    priority: 100  # Override other blocks
    filter:
      title_pattern: ".*Christmas.*|.*Holiday.*"
      genres: ["Family", "Comedy"]

πŸ—οΈ Architecture

Project Structure
schedularr/
β”œβ”€β”€ main.go                    # Entry point
β”œβ”€β”€ api/
β”‚   └── openapi.yaml           # OpenAPI 3.0.3 contract (source of truth for internal/api/gen)
β”œβ”€β”€ cmd/                        # CLI commands (Cobra)
β”‚   β”œβ”€β”€ root.go
β”‚   β”œβ”€β”€ channels.go             # List Tunarr channels
β”‚   β”œβ”€β”€ generate.go             # Generate & apply schedules
β”‚   β”œβ”€β”€ serve.go                # HTTP API server + cron scheduling loop
β”‚   β”œβ”€β”€ validate.go             # Config validation
β”‚   β”œβ”€β”€ state.go                # Series state management
β”‚   β”œβ”€β”€ config.go               # App config generation/dump
β”‚   β”œβ”€β”€ health.go               # Standalone healthz/livez probe server
β”‚   β”œβ”€β”€ scheduler.go            # scheduler.yaml import-file authoring
β”‚   └── schema/                 # CUE schemas for validation
β”‚       β”œβ”€β”€ config.cue
β”‚       └── scheduler.cue
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ config/                 # CUE-based config loading (see internal/cueconfig)
β”‚   β”œβ”€β”€ cueconfig/               # CUE schema compilation, validation, generation
β”‚   β”œβ”€β”€ scheduler/                # Core scheduling engine
β”‚   β”‚   β”œβ”€β”€ engine.go             # GenerateForTimeRange, PlanBlock, PlanSeriesBlock
β”‚   β”‚   β”œβ”€β”€ filter.go             # Genre/rating/year/duration/title filters
β”‚   β”‚   β”œβ”€β”€ history.go            # Schedule history (prevent repeats)
β”‚   β”‚   └── types.go
β”‚   β”œβ”€β”€ external/tunarr/          # Tunarr REST API client
β”‚   β”œβ”€β”€ store/                    # SQLite persistence (blocks, series state, history)
β”‚   β”‚   └── migrations/
β”‚   β”œβ”€β”€ api/                      # HTTP API: router, handlers, generated gen.ServerInterface
β”‚   β”‚   └── gen/                  # server.gen.go -- generated, do not hand-edit
β”‚   β”œβ”€β”€ service/                   # Schedule generate/apply workflow (shared by CLI + API)
β”‚   β”œβ”€β”€ blockio/                   # scheduler.yaml parse/render + first-run store import
β”‚   β”œβ”€β”€ problem/                   # RFC 7807 application/problem+json helpers
β”‚   β”œβ”€β”€ metrics/                   # Prometheus metrics registration
β”‚   β”œβ”€β”€ cache/                     # In-memory caching
β”‚   └── httpclient/                # HTTP client with retry
β”œβ”€β”€ configs/
β”‚   └── config.yaml              # Example configuration
β”œβ”€β”€ e2e/                          # Docker-based acceptance tests against a real Tunarr
β”œβ”€β”€ web/                           # Hugo web UI, embedded via go:embed (see Web UI section)
β”‚   β”œβ”€β”€ DESIGN.md                    # Shipped design system: tokens, components, WCAG evidence, Alpine rules
β”‚   β”œβ”€β”€ hugo.toml                    # Site config (baseURL, disabled kinds)
β”‚   β”œβ”€β”€ package.json                  # devDeps: typescript, openapi-typescript
β”‚   β”œβ”€β”€ tsconfig.json                  # Strict TS config for web/assets/ts
β”‚   β”œβ”€β”€ embed.go                       # package web -- //go:embed all:public, web.Site()
β”‚   β”œβ”€β”€ layouts/                       # Hugo templates
β”‚   β”‚   β”œβ”€β”€ _default/baseof.html         # Shell: header/nav/token-panel/footer, page_js hook
β”‚   β”‚   β”œβ”€β”€ partials/nav.html            # Primary channel-select nav
β”‚   β”‚   β”œβ”€β”€ index.html                   # Dashboard ("/")
β”‚   β”‚   β”œβ”€β”€ 404.html                     # Styled not-found page, composed through baseof
β”‚   β”‚   β”œβ”€β”€ blocks/list.html              # Blocks ("/blocks/")
β”‚   β”‚   β”œβ”€β”€ schedule/list.html             # Schedule ("/schedule/")
β”‚   β”‚   └── series/list.html               # Series ("/series/")
β”‚   β”œβ”€β”€ content/                       # Hugo section front matter (blocks/, schedule/, series/ _index.md)
β”‚   β”œβ”€β”€ assets/
β”‚   β”‚   β”œβ”€β”€ css/main.css               # hand-written, one file, CSS custom properties (light/dark)
β”‚   β”‚   β”œβ”€β”€ ts/                        # api.ts, token.ts, main.ts; gen/types.d.ts is generated
β”‚   β”‚   β”‚   └── pages/                   # dashboard.ts, blocks.ts, schedule.ts, series.ts
β”‚   β”‚   └── vendor/alpine.min.js       # Alpine.js, vendored (pinned 3.16.3, no CDN)
β”‚   └── public/                        # Hugo build output (gitignored; index.html placeholder committed)
└── docs/
    β”œβ”€β”€ ARCHITECTURE.md
    └── SPECIFICATIONS.md
Key Technologies
  • Language: Go 1.27
  • CLI framework: Cobra
  • Configuration: CUE schemas (cmd/schema/, internal/cueconfig), not Viper
  • HTTP API: chi router, generated from api/openapi.yaml via oapi-codegen
  • Persistence: SQLite (mattn/go-sqlite3), migrated with golang-migrate
  • Cron parsing: robfig/cron

πŸ”Œ API

Schedularr exposes an HTTP API defined by an OpenAPI 3.0.3 contract at api/openapi.yaml. The contract covers blocks CRUD, block import/export, schedule generation and application, history, series state, channels, and status.

Server code is generated from the contract with oapi-codegen v2:

make generate

This writes internal/api/gen/server.gen.go, which is committed and must not be edited by hand β€” change api/openapi.yaml and regenerate instead. Handlers live in internal/api/ and implement the generated gen.ServerInterface. Errors use an RFC 7807 application/problem+json body (internal/api/problem.go, backed by internal/problem).

The API is served by schedularr serve (internal/api/router.go, cmd/serve.go) β€” see Serve below.

Blocks Endpoints

Blocks CRUD (internal/api/blocks.go) is implemented against gen.ServerInterface and backed by the sqlite block store (internal/store). Every write path (POST/PUT) validates the block spec against the CUE scheduler schema via blockio.ValidateBlocks before touching the store, and every response body is application/json (or application/problem+json for errors).

Method Path Success Error codes
GET /blocks 200 β€”
POST /blocks 201 400, 409
GET /blocks/{id} 200 404
PUT /blocks/{id} 200 400, 404, 409
DELETE /blocks/{id} 204 404

Notes:

  • POST/PUT return 400 for a spec that fails CUE validation (e.g. a missing cron or a non-positive duration) or a malformed JSON body.
  • POST returns 409 for a duplicate block name; PUT returns 409 if the request body's spec.name differs from the existing block's name and collides with another block. A PUT whose spec.name differs from the current name without colliding renames the block.
  • POST/PUT also return 400 for a series block (spec.type: series) whose series[].show_title is empty. The CUE scheduler schema types show_title as a bare string with no non-empty constraint, so this case would otherwise pass CUE validation; the check is applied in Go on both block-ingestion paths (blocks CRUD here, and blocks/import below).
Import/Export Endpoints

Block import/export (internal/api/importexport.go) round-trips the same sqlite-backed blocks through blockio.ParseYAML/blockio.RenderYAML (internal/blockio) used for the on-disk scheduler.yaml bootstrap path. Both endpoints exchange raw YAML text, not JSON: oapi-codegen does not generate a Go type for an application/yaml request or response body, so the handlers read/write []byte directly.

Method Path Success Error codes
POST /blocks/import 200 400, 409, 413
GET /blocks/export 200 β€”

Notes:

  • POST /blocks/import takes an application/yaml body (capped at 1MiB via http.MaxBytesReader; an oversized body gets 413) and an optional ?dry_run=true query parameter (default false). The body is strictly decoded and CUE-validated by blockio.ParseYAML, including duplicate block-name and empty-show_title rejection -- any failure there is 400 with the CUE detail included. Every parsed block's name is then checked against every block already in the store; any collision is 409 (listing the colliding name(s)) with zero writes, even for the non-colliding blocks in the same batch. dry_run=true stops after that check and reports what would have been imported ({imported, dry_run, names}) without writing anything; otherwise every block is created with a fresh UUID and enabled: true.
  • GET /blocks/export renders every stored block's spec as YAML via blockio.RenderYAML -- including disabled blocks, since export doubles as a backup mechanism and silently dropping disabled blocks would make a restored import lossy. The response has no enabled state of its own (that lives on the store record, not the spec); re-importing an exported file creates every block as enabled.
Schedule Endpoints

Schedule generation and application (internal/api/schedule.go) delegate to internal/service.Runner (Deps.Sched, a service.ScheduleRunner), which is the extraction of what used to be cmd/generate.go's inline generate/apply flow: load the enabled blocks (service.ActiveBlocks, moved from the CLI's former loadActiveBlocks), fetch available Tunarr content, run scheduler.Engine.GenerateForTimeRange over a days-wide window starting now, and -- only when applying -- push the result to Tunarr per channel via UpdateSchedule and commit the engine's pending state via Engine.Commit(). cmd/generate.go now calls the same service.Runner, so the CLI and the API share one implementation.

Method Path Success Error codes
POST /generate 200 400, 502
POST /apply 200 400, 502
GET /schedule?days=N 200 400, 502

Notes:

  • POST /generate and POST /apply share the same optional GenerateRequest body (days, channel_id); GET /schedule takes the same days as a query parameter. days defaults to 7 and (matching the GetHistory convention -- oapi-codegen's generated bindings don't enforce the OpenAPI schema's default/minimum/maximum) is range-checked by the handler itself against [1, 30], returning 400 outside that range.
  • POST /generate always runs a dry run (applied: false in the response) regardless of the request body -- it never mutates the store or Tunarr. Only POST /apply (applied: true on success) pushes anything.
  • channel_id, when set, restricts which blocks get planned at all -- not just which channels appear in the response or get pushed via UpdateSchedule. Runner.Run filters the active blocks down to that channel's before handing them to scheduler.Engine, so a channel-scoped POST /apply never touches Tunarr, schedule history, or series-cursor state for any other channel: scheduler.Engine mutates pending series-state and history for every block it plans, so filtering only the result map after planning (an earlier version of this behavior) would still have let Engine.Commit() persist state for channels the request never asked about, even though nothing was pushed to Tunarr for them.
  • A Runner.Run failure (loading blocks, fetching Tunarr content, generating the schedule, or -- on apply -- UpdateSchedule/Commit) returns 502 (title: "schedule generation failed") with a short, fixed detail: the underlying error can wrap a raw store/driver error, so (matching the internal-error convention used elsewhere in this package) it's logged server-side only, never echoed in the response body.
History Endpoint

History (internal/api/history.go) lists schedule_history rows (backed by store.ListScheduleHistory, ordered by scheduled_at DESC) scheduled within the last days days.

Method Path Success Error codes
GET /history?days=N 200 400

Notes:

  • days defaults to 7 when omitted. The OpenAPI schema declares minimum: 1 / maximum: 90 for days, but oapi-codegen's chi-server generator does not enforce a schema's default/minimum/maximum at the binding layer -- it only type-checks the raw query value. The handler applies the default and range check itself, returning 400 for any days outside [1, 90].
  • days only has data to return as far back as maintenance.history_retention (default 168h/7 days) allows: service.NewRunner threads that config value into every scheduler.Engine it builds (scheduler.EngineOptions.HistoryWindow), and Engine.Commit() prunes schedule_history to that same window on every apply. Requesting ?days=90 when history_retention is still at its 7-day default returns only the last 7 days' worth of rows -- set history_retention to at least the widest days value you intend to query (e.g. 2160h for a full 90-day window) for GET /history?days=90 to actually have 90 days of data available.
Series State Endpoints

Series state (internal/api/state.go) lists and patches the per-show series_state tracking rows (current season/episode, completion, and the disabled flag the scheduler sets once a non-restarting series runs out of episodes) backed by the same sqlite store as blocks.

Method Path Success Error codes
GET /state/series 200 β€”
PATCH /state/series/{show_title} 200 400, 404

Notes:

  • PATCH applies a partial update: only fields present in the request body (current_season, current_episode, completed, disabled) change, and a body with none of them set returns 400, as does a malformed JSON body.
  • PATCH returns 404 for a show_title with no persisted series_state row. This intentionally does not reuse store.GetSeriesState, which fabricates a default S01E01 state for any show (tracked or not) as a convenience for scheduling callers; the handler instead uses store.GetPersistedSeriesState, added alongside it, which returns ErrNotFound when no row exists.
Channels and Status Endpoints

Channels and status (internal/api/tunarr.go) are the Tunarr boundary: ListChannels proxies GET /api/channels on the configured Tunarr instance via a TunarrAPI interface (GetChannels(ctx) ([]tunarr.Channel, error)) added to Deps, and GetStatus reports overall service health, probing Tunarr reachability through the same interface. Production wiring passes a *tunarr.Client (it satisfies TunarrAPI unmodified); Deps.Tunarr may also be nil, meaning "no Tunarr integration configured" -- both handlers treat that the same as a Tunarr connectivity failure, not a programming error.

Method Path Success Error codes
GET /channels 200 502
GET /status 200 β€”

Notes:

  • GET /channels returns 502 (title: "tunarr unreachable") both when Deps.Tunarr is nil (detail: "tunarr not configured") and when the configured client's GetChannels call fails (detail carries the wrapped connectivity error, e.g. a dial failure -- an upstream reachability message, not an internal leak).
  • GET /status never returns a 5xx. It always responds 200 with version (Deps.Version), tunarr_reachable (a live probe via GetChannels), tunarr_error (set whenever tunarr_reachable is false, whether from a nil client or a failed probe), and blocks (store.CountBlocks). A CountBlocks failure is logged server-side and blocks is simply omitted from the response rather than failing the request.
Middleware

internal/api/middleware provides the four pieces of middleware every /api/v1/* route will run through once the router is wired up:

  • Request ID β€” generates a fresh identifier for every request (an inbound X-Request-Id header is never trusted), returns it on the response as X-Request-Id, and makes it available to api.WriteProblem so every problem+json body includes the same id.
  • Logging β€” writes one structured slog line per request with the keys method, path, status, duration_ms, request_id.
  • Recovery β€” turns a panic in a handler into a 500 application/problem+json response and logs it with a stack trace, instead of crashing the process.
  • Bearer auth β€” requires Authorization: Bearer <token> on protected routes. The token is compared as a SHA-256 digest via crypto/subtle.ConstantTimeCompare, and a token under 32 characters is rejected when the middleware is constructed. A missing or wrong token gets a 401 problem+json response.

schedularr serve's own system endpoints β€” /healthz, /readyz, /metrics, /openapi.json β€” are not part of the OpenAPI contract and sit outside this middleware chain entirely (see Serve below). The separate schedularr health command's /healthz//livez endpoints are a standalone, unrelated probe server, unaffected by this package.


πŸš€ Serve (API server + cron)

schedularr serve runs the HTTP API and the cron scheduling loop in one long-lived process β€” the API server, the block store, and the periodic schedule generate-and-apply cycle all share one process and one graceful shutdown path (internal/api/router.go, cmd/serve.go).

SCHEDULARR_API_TOKEN=$(openssl rand -hex 32) schedularr serve --listen :8484
Flags
Flag Default Description
--listen :8484 Address the HTTP API server listens on
--insecure-no-auth false Skip bearer-token auth on /api/v1/* β€” local development only, never a real deployment (logs a WARN at startup when set)
--interval/-i 6h Interval between cron-driven schedule generate-and-apply cycles
Environment and config keys
Config key Env var Default Description
api.listen β€” :8484 Same as --listen; the flag wins when explicitly passed
api.token SCHEDULARR_API_TOKEN "" Bearer token required on /api/v1/*. The env var always wins over this key when both are set
api.insecure_no_auth β€” false Same as --insecure-no-auth; either source turning it on disables auth
cron_interval β€” 6h Same as --interval/-i; the flag wins when explicitly passed. Top-level key, not under api.* -- it governs the cron loop, not the HTTP server

schedularr serve refuses to start if the effective token is empty (or shorter than 32 characters) and --insecure-no-auth/api.insecure_no_auth is not set.

Endpoints
Method Path Auth Description
GET /healthz none Process liveness only, no dependency checks
GET /readyz none Liveness plus a store round-trip (SELECT 1)
GET /metrics none Prometheus text exposition
GET /openapi.json none The OpenAPI 3.0 contract as JSON
* /api/v1/* bearer Blocks CRUD, import/export, generate/apply/schedule, history, series state, channels, status β€” see API above
Cron loop

On an interval (--interval/-i, or the cron_interval config key, default 6h either way -- flag wins when passed explicitly) and once immediately at startup, serve regenerates and applies the next day's schedule β€” the same service.Runner.Run(ctx, Options{Days: 1, Apply: true}) call schedularr generate --apply --yes makes, just on a timer instead of a one-shot CLI invocation. A failed tick is logged and does not stop the server; the next tick tries again.

Shutdown

serve listens for SIGINT/SIGTERM. On either, it stops accepting new HTTP connections, waits up to 15s for in-flight requests to finish (http.Server.Shutdown), then stops the cron loop and closes the store β€” in that order, so an in-progress schedule apply isn't cut off mid-write by the HTTP shutdown deadline.

Running it

serve is a plain long-lived process: run it under whatever supervisor manages the rest of your deployment (a systemd unit with Restart=on-failure, a Docker/Podman container, a Kubernetes Deployment, ...). It has no built-in daemonization β€” foreground it and let the supervisor handle restarts and logging, the same way you'd run any other Go server binary.


πŸ–₯️ Web UI

A Hugo-built web UI lives in web/ and is embedded into the schedularr binary via go:embed (web/embed.go, package web, web.Site()). Nothing under web/public/ is tracked in git; make web-presence (a prerequisite of make build) writes a one-line placeholder there on demand when it's missing, so go build ./... keeps working without Hugo installed. That placeholder has no 404.html of its own, but internal/api/ui.go's newUIHandler already falls back to a plain-text 404 when the embedded site lacks one (see below) -- a fresh clone without make web gets that fallback, not a styled 404 page. A release build (the Docker image, see Docker) always runs the real hugo --minify -s web first and never ships the placeholder.

schedularr serve mounts web.Site() as internal/api.Config.UI and serves it from the router's catch-all NotFound handler: the four system routes (/healthz, /readyz, /metrics, /openapi.json) and /api/v1/* still win first, and everything else falls through to the embedded site. A directory request resolves to that directory's index.html (/ β†’ index.html, /blocks/ β†’ blocks/index.html); the same request without its trailing slash (/blocks) gets a 301 redirect to the slash form, like net/http.FileServer. A path that matches no file serves 404.html with HTTP 404 (falling back to a plain-text 404 if the embedded site has no 404.html); non-GET/HEAD requests get a 405. Every response the UI handler serves carries X-Content-Type-Options: nosniff, Referrer-Policy: same-origin, and a Content-Security-Policy:

Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self'; img-src 'self' data:; connect-src 'self'; frame-ancestors 'none'

Every directive is 'self'/'none' -- the site vendors Alpine (no CDN) and only ever calls its own origin's /api/v1, so there's no third-party origin to allow anywhere. 'unsafe-eval' is required by Alpine.js 3, which evaluates directive expressions via new Function(...); see web/DESIGN.md's Content-Security-Policy section for the full rationale, including the inline-style= footgun this policy creates for any future page (style-src 'self' silently drops inline style declarations -- use a CSS class instead) and how the shipped skeleton-loading bars were fixed when it caught them. Content-Type comes from the resolved file's extension via http.ServeContent. An unmatched /api/v1/* path still answers its own JSON problem+json 404 rather than the UI's HTML page (internal/api/router.go's apiNotFoundHandler). See internal/api/ui.go for the implementation.

Prerequisites
  • Hugo β‰₯ 0.120 β€” brew install hugo (tested with 0.165.0)
  • Node.js with npm β€” only used to generate and type-check TypeScript; not required to build the Go binary (tested with Node 26.7.0 / npm 12.0.2)
Building the UI
# One-time: install the npm devDependencies (typescript, openapi-typescript)
npm install --prefix web

# Regenerate TS types from api/openapi.yaml, type-check, then build with Hugo
make web

# Individual steps -- each is now a real prerequisite of the next (so
# `make -j` can't interleave them): web-check depends on web-types,
# web-build depends on web-check, web depends on web-build. Invoking any
# one of them also runs everything it depends on.
make web-types  # openapi-typescript -> web/assets/ts/gen/types.d.ts
make web-check  # web-types, then tsc --noEmit (skipped with a notice if npm is absent)
make web-build  # web-check, then hugo --minify -s web -> web/public

make build depends on web-presence, not on a real Hugo build: it only requires web/public/index.html to exist, writing the placeholder above when it doesn't (see Makefile). This keeps go build/make build working on a machine without Hugo or Node installed -- the whole point of the placeholder -- while web/public/ itself stays untracked, so there's no committed file for a real make web run to dirty and nothing to git restore before committing. Run make web (or make web-build) whenever you want the actual UI in web/public instead of the placeholder; the release build (Docker) always does this for you, never the placeholder -- see Docker.

web/assets/ts/gen/types.d.ts is committed and regenerated by make web-types; hand-editing it is pointless since make web overwrites it.

Shell, Client, and Design System

web/DESIGN.md is the full design-system reference β€” token inventory, component-class catalog, the light/dark mechanism, WCAG contrast evidence, and the Alpine.js conventions below. This section is a summary; DESIGN.md is the source to check before adding a new page or component.

The shell (web/layouts/_default/baseof.html, web/layouts/partials/nav.html) gives every page a header (product wordmark, primary nav, a token button), a <main> content block, and a token panel (a native <dialog>). Pages extend it with {{ define "main" }}...{{ end }} β€” see web/layouts/index.html for the pattern.

Styling is one hand-written file, web/assets/css/main.css β€” no CSS framework, no utility classes. It defines CSS custom properties for color, type, space, and motion, with a light palette on :root and a dark palette under @media (prefers-color-scheme: dark); there is no manual theme toggle, the OS/browser setting decides. Alpine.js is vendored at web/assets/vendor/alpine.min.js (pinned 3.16.3, the official npm dist/cdn.min.js build, sha256 e31d6d92aefd41979d3c66f994d3a6b77fafa5062aec67d13f3ec5099d70d5d6) and loaded defer β€” there is no CDN reference anywhere in the templates.

web/assets/ts/api.ts and web/assets/ts/token.ts are the only modules allowed to touch fetch/localStorage for API calls β€” every page module goes through them:

  • apiGet<T>(path) / apiSend<T>(method, path, body?) β€” attach Authorization: Bearer <token> when a token is stored, decode a JSON (or, for /blocks/export, plain-text YAML) response body as T.
  • ApiError β€” thrown for any non-2xx response; carries the parsed problem+json fields (type, title, status, detail, request_id).
  • onUnauthorized(cb) β€” cb fires on every 401 response. The shell registers one that opens the token panel; there is no automatic retry of the request that failed.
  • ApiResponse<Op, Status> / ApiRequestJSON<Op> β€” small generic aliases over the generated operations type (web/assets/ts/gen/types.d.ts) so page code reads ApiResponse<"listBlocks", 200> instead of the full operations["listBlocks"]["responses"][200]["content"]["application/json"] chain.

web/assets/ts/main.ts is the shell's own bundle (built once, loaded on every page): it publishes window.schedularr (apiGet, apiSend, ApiError, getToken, setToken, clearToken) so later page bundles share one compiled copy instead of re-bundling the client, and wires the token panel described below.

Token Setup

The UI talks to /api/v1 with the same bearer token schedularr serve was started with (SCHEDULARR_API_TOKEN or api.token β€” see Environment and config keys above). The token lives only in the browser's localStorage (key schedularr_api_token) and is attached to every API request; it is never embedded in the served HTML/JS.

  1. Open the UI (http://<host>:8484/ by default). With no token stored, the Arm API Token panel opens automatically.
  2. Paste the same token the server was started with. The input is masked; click the eye icon to reveal it before saving.
  3. Save persists it and closes the panel. Clear wipes it (and leaves the panel open). The panel is reachable anytime via the Token button in the header β€” the status dot next to it reflects whether a token is currently stored, not whether it's valid.
  4. If any API call comes back 401 (wrong or expired token), the panel reopens automatically with an inline error. Saving a new token does not retry the action that failed β€” repeat it once the token is updated.
Page Tour
Dashboard (/)

The landing page. Two sections, each fetched independently on load (web/assets/ts/pages/dashboard.ts, bundled separately from the shell via the page_js template hook):

  • System status β€” reads GET /api/v1/status: the server version, a Tunarr signal indicator, and the current block count. A Tunarr that can't be reached renders as a normal instrument reading, not an error: the status dot flips to "No Signal" and the server's own tunarr_error text prints inline underneath it. /status reports this as a state, and Tunarr being down doesn't mean Schedularr itself is broken.
  • Recent History β€” reads GET /api/v1/history?days=7: a table of what has aired (scheduled time in the browser's local timezone, not the UTC wire value, plus channel, block, and program ID). An empty result renders an explanatory empty state ("Nothing has aired yet...") rather than an empty table shell.

Both sections load, error, and empty-state independently: a failed /status call doesn't block history from rendering, and vice versa. A failure renders the API's problem+json title/detail inline, next to the section that failed, with a Retry button β€” never a toast. Alpine's x-text sets textContent, so a detail string containing HTML stays literal text; nothing on this page goes through innerHTML.

Blocks (/blocks/)

List every stored block and create/edit/delete them, backed entirely by GET/POST/PUT/DELETE /api/v1/blocks[/{id}] (web/assets/ts/pages/blocks.ts). One page, no routing between list and editor: a + New Block button and each row's Edit open an inline panel above the list (not a native <dialog> β€” this form is a multi-minute task, long enough that interrupting the page for it isn't worth it), which auto-scrolls into view and focuses the name field when it opens.

List β€” name, a type badge (filter/series), the raw cron plus a plain-language hint underneath it when the pattern is recognized (see "Cron hint" below), channel_id, an Enabled/Disabled toggle, and Edit/Delete. Delete requires a second click ("Delete" β†’ inline Confirm/Cancel, not a native confirm() dialog) before anything is sent. Both the toggle and every editor save use PUT /api/v1/blocks/{id} with the full BlockWrite body β€” enabled is always sent explicitly (the API defaults an omitted enabled to true on write, and this UI never relies on that default) and the toggle sends the block's own stored spec back byte-for-byte unchanged, since PUT has no partial-update form.

Editor β€” common fields: name, cron, duration (minutes), channel, priority, max duration overflow (minutes), and enabled. channel_id is a <select> populated from GET /api/v1/channels when Tunarr answers with at least one channel; it falls back to a free-text input (with an inline reason) when the call fails or returns nothing β€” same "legitimate reading, not an error" treatment as the dashboard's Tunarr status. Editing a block whose stored channel_id isn't in that list keeps it selectable (labeled "not in Tunarr's channel list") instead of silently swapping the channel out from under the operator on save.

Editor β€” type: filter shows genres/ratings/title-pattern(regex)/year range/duration range/tags (comma-separated inputs map to arrays; an empty input omits the field, it is never sent as []). series shows repeating rows (show title, episodes per block, start season/episode, on-complete, skip-episodes, max runs β€” add/remove freely) plus a fallback section (redistribute/filler, with a nested filter subset when filler is chosen). A Filler section (enabled, filler list ID, max filler time, min gap time) is available for either type, since BlockSpec.filler isn't gated by type in the schema. Every section maps 1:1 onto BlockSpec β€” nothing is invented, and the submitted JSON only ever contains fields the operator actually filled in, plus type and enabled (always explicit).

Cron hint β€” a small hand-rolled reader for common 5-field patterns (fixed time, optionally restricted to specific weekdays: "0 20 * * 6" β†’ "Saturdays at 20:00", "0 6 * * *" β†’ "Daily at 06:00", weekday/weekend groups collapse to "Weekdays"/"Weekends"), not a cron-parsing dependency. Anything outside that shape (a day-of-month/month restriction, a list on minute/hour) shows no hint β€” only the raw cron β€” rather than guessing wrong.

Validation β€” skip_episodes is checked client-side against SxxExx (e.g. S01E05) before submit, with the exact invalid token(s) named inline; everything else (missing/invalid required fields, a duplicate name) is left to the API. A 400 renders its title/detail inline near the submit button; a 409 (duplicate name) renders under the name field specifically, not mixed in with the generic error.

Schedule (/schedule/)

Preview a schedule, then apply it β€” a dry-run/apply pair backed by POST /api/v1/generate and POST /api/v1/apply (web/assets/ts/pages/ schedule.ts), the same GenerateRequest body (days, optional channel_id) as the CLI's generate/generate --apply. No timeline graphic: a chronological list per channel, per the design's explicit v1 non-goal ("no charts/graphics for the schedule timeline").

Controls β€” a days number input (1–30, defaulting to 7, clamped client-side to that range before every request β€” matching /generate's/ /apply's own server-side bounds β€” with the API's 400 as the backstop for anything the clamp doesn't catch) and a channel_id scope: a <select> (first option always All channels) populated from GET /api/v1/channels when Tunarr answers with at least one channel, falling back to free text (blank still means all channels) on the same "legitimate reading, not an error" terms as the dashboard's Tunarr status and the blocks editor's channel field.

Preview β€” Generate Preview sends POST /api/v1/generate, which always dry-runs (PlanResult.applied is always false). Each channel in the response renders as its own section: slots listed chronologically with start/end in the browser's local timezone, the block name (slot.block.name), and a program count that expands (<details>) into the individual program titles when the slot has any β€” ScheduledSlot. programs is an untyped additionalProperties: true array in api/openapi.yaml, so a title is read defensively (a real Tunarr program always has one; a missing one renders as an em dash rather than being invented). A visible Preview β€” nothing applied readout (a status dot

  • text, same coded-legend convention as the Tunarr/token indicators) makes the dry-run state explicit. A scope with no matching channels renders its own empty state ("No channels matched this scope") rather than an empty table shell.

Apply β€” disabled until a preview has run for the exact controls currently on screen: editing days or the channel scope after a preview invalidates it immediately (an inline hint explains why), and a fresh Generate Preview is required to re-arm it β€” the web equivalent of the CLI's --yes gate (cmd/generate.go's checkApplyGate), applied per action rather than once per process. Clicking Apply opens a native <dialog> confirmation naming the scope exactly: "Apply ALL channels" or "Apply channel <id>", plus a real slot/channel count summary β€” or, when the previewed plan has no channels, "There is nothing to apply for this scope" (applying an empty plan is allowed, it's just a no-op against Tunarr). Confirming sends POST /api/v1/apply with the identical body the preview used β€” note that /apply does not replay the previewed plan; it independently re-runs the same generate-and-push workflow server-side (internal/service.Runner.Run), so "the same body" means the same request, not a cached payload. A successful apply flips the readout to Applied with a summary line (slot/channel counts and a local timestamp) and immediately disables Apply again, even if the controls haven't changed β€” an applied plan is a past action, not a standing offer to repeat it with one more click. A 502 (title: "schedule generation failed") from either /generate or /apply renders inline as a .problem panel with the API's own title and detail shown verbatim, not folded into one string like the dashboard's/blocks' generic error label.

Series (/series/)

Every persisted series_state row β€” the per-show season/episode cursor a series block advances as it airs β€” backed by GET/PATCH /api/v1/state/series[/{show_title}] (web/assets/ts/pages/series.ts). There is no create endpoint and this page never offers one: a row exists only once a series block airs that show for the first time (internal/api/state.go's own words, "the store fabricates nothing for the API"), so an empty result renders an explanatory empty state rather than an empty table shell.

List β€” show title, an inline SxxEyy cursor editor, run count, last aired (local time, or an em dash for a show that hasn't aired yet), and a Completed/In Progress toggle plus a Disabled/Active toggle (the same coded-legend switch component as the blocks list's Enabled/Disabled toggle β€” the text label always carries the state, never color alone).

Cursor editing β€” season and episode are two adjacent number inputs (min="1") framed by S/E prefixes, so the pair still reads as one SxxEyy value at a glance while staying independently editable, inline, in the same cell β€” no separate edit mode. Save stays disabled until the row is actually dirty (its text differs from the loaded value) and, on click, sends a true partial PATCH: only current_season and/or current_episode land in the body, and only when their parsed value actually differs from what was loaded β€” editing a field back to its original value (or clicking Save with nothing touched) sends zero requests, checked both by the disabled button and, independently, by the save handler's own diff against the loaded row (buildCursorPatch in series.ts). A season/episode value that isn't a whole number >= 1 is rejected client-side with an inline message and never reaches the API; anything else invalid (e.g. a value the show doesn't actually have) is left to the API's own 400. Each toggle is its own single-field PATCH ({"completed": true} or {"disabled": true} alone) β€” never the cursor fields riding along.

show_title in the URL β€” titles routinely contain spaces and punctuation (Star Trek: The Next Generation), so every PATCH path runs the title through encodeURIComponent before it's sent, matching how the server's own test suite constructs the same path (internal/api/state_test.go's url.PathEscape).

Row vanishes mid-edit β€” a save against a show_title whose series_state row was deleted or reset out from under the operator (between page-load and Save) returns 404. The row stays on screen with an inline error and a Refresh list action next to the show title β€” re-running the GET, which naturally drops the now-gone row β€” rather than a row that silently can never save again; Save itself stays disabled on that row until the list is refreshed.


🐳 Docker

docker build runs the same pipeline as make web && make build, inside the image, from a bare checkout β€” no local Hugo, Node, or Go required. Dockerfile is four stages: node:22-alpine regenerates and type-checks the TypeScript (tsc --noEmit), a pinned Hugo release binary runs hugo --minify -s web, golang:1.27-alpine builds the binary against that real UI output, and alpine:3.20 is the runtime. The image never embeds the web/public/index.html placeholder described above β€” the Hugo stage always builds the real site first.

CGO is required. internal/store persists through mattn/go-sqlite3, a cgo binding over the sqlite3 C amalgamation with no pure-Go build tag, so CGO_ENABLED=0 isn't an option here. The build stage links against musl (Alpine's default gcc target); the final stage is Alpine too, matching libc between build and run. A distroless/static final image is not viable with this dependency.

# Build (VERSION stamps GET /api/v1/status and cmd.Version, default "dev")
docker build --build-arg VERSION=v1.2.3 -t schedularr:v1.2.3 .
# or: make docker-build VERSION=v1.2.3

# Run: mount a config file and pass the API token via env, never the config
docker run -d --name schedularr \
  -p 8484:8484 \
  -v "$(pwd)/config.yaml:/etc/schedularr/config.yaml:ro" \
  -v schedularr-data:/data \
  -e SCHEDULARR_API_TOKEN="$(openssl rand -hex 32)" \
  schedularr:v1.2.3

The image's default CMD is serve --config /etc/schedularr/config.yaml (ENTRYPOINT ["schedularr"], so any docker run ... schedularr:tag <args> replaces it with another subcommand instead). Point the mounted config's database and scheduler_file keys at paths under /data explicitly β€” both are resolved relative to the process's working directory, not the config file's location (see Configuration). The container runs as a non-root schedularr user (uid 1001), exposes 8484 (api.listen's default), and its HEALTHCHECK polls GET /healthz on that port.

Build arg Default Purpose
VERSION dev Stamped via -ldflags -X .../cmd.Version=...; reported by GET /api/v1/status
GO_VERSION 1.27 golang:${GO_VERSION}-alpine build stage
NODE_VERSION 22 node:${NODE_VERSION}-alpine TypeScript stage
ALPINE_VERSION 3.20 Hugo-fetch and final runtime stage
HUGO_VERSION 0.165.0 Pinned Hugo release, downloaded and sha256-verified in-stage

make docker-build is a thin wrapper (DOCKER_IMAGE/DOCKER_TAG/VERSION Makefile variables, default schedularr:latest/dev).


🏷️ Release Process

Two workflows in .github/workflows/ (GitHub-authored actions only β€” actions/checkout, actions/setup-go, actions/setup-node β€” no third-party marketplace actions):

ci.yaml β€” every push and PR to main
Job Checks
go golangci-lint run (pinned to match local, config .golangci.yml), gosec ./..., govulncheck ./..., go test -race ./...
drift make generate and make web-types must produce no diff against the committed internal/api/gen/ and web/assets/ts/gen/ output
web tsc --noEmit against the freshly regenerated TS types
docker docker build --build-arg VERSION=ci . (no push) β€” proves the image still builds

Go tool versions are pinned in ci.yaml's env: block and installed with go install ...@<version> (not a marketplace action) so CI enforces exactly what make lint enforces on a dev machine. Bump them there alongside any local upgrade.

release.yaml β€” on v* tag push

Builds the image with --build-arg VERSION=<tag> (stamps cmd.Version, see Docker) and pushes two tags to GHCR:

ghcr.io/christopherime/schedularr:<tag>   # e.g. v0.1.0
ghcr.io/christopherime/schedularr:latest

Auth is a plain docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} with permissions: contents: read, packages: write β€” no PAT, no docker/login-action.

Cutting a release
git tag v0.1.0
git push origin v0.1.0

Watch it with gh run watch or gh run list --workflow=release.yaml. The tag is the only source of truth for the image version β€” there is no separate "bump version" commit.

Package visibility

schedularr is a private repository; a package published to GHCR from a private repo defaults to private as well, which the cluster's anonymous imagePullPolicy can't pull. Making the package public is a one-time, human-only step (not automatable via API or PAT β€” GitHub requires the interactive confirmation):

GitHub UI β†’ repo β†’ Packages β†’ schedularr β†’ Package settings β†’ Danger Zone β†’ Change visibility β†’ Public

Do this once after the first release.yaml run publishes the package. Source code visibility is unaffected β€” only the container package becomes public.


πŸ§ͺ Development

Running Tests
# Run all tests
go test ./...

# Run with coverage
go test -cover ./...

# Run specific package tests
go test ./internal/scheduler/...
Building
# Development build
go build -o schedularr main.go

# Stripped build with a version stamp (reported by GET /api/v1/status)
go build -ldflags="-s -w -X github.com/christopherime/schedularr/cmd.Version=1.2.3" -o schedularr main.go

# Cross-compilation
GOOS=linux GOARCH=amd64 go build -o schedularr-linux main.go

make build runs the equivalent of the first form (see Makefile).

Code Quality
# Format code
go fmt ./...

# Lint
golangci-lint run

# Vet
go vet ./...

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Workflow
  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request
Guidelines
  • Write tests for new features
  • Follow Go best practices and idioms
  • Update documentation as needed
  • Ensure all tests pass before submitting PR

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Tunarr - the TV channel management platform this project schedules for
  • Cobra - CLI framework

πŸ“ž Support


Made with ❀️ by christopherime

⭐ Star this repo if you find it useful!

Documentation ΒΆ

Overview ΒΆ

Package main is the entry point for the Schedularr CLI application.

Directories ΒΆ

Path Synopsis
cmd
Package cmd provides command-line interface commands for Schedularr.
Package cmd provides command-line interface commands for Schedularr.
schema
Package schema provides embedded CUE schemas for Schedularr configuration.
Package schema provides embedded CUE schemas for Schedularr configuration.
internal
api
Package api implements the Schedularr HTTP API defined by api/openapi.yaml.
Package api implements the Schedularr HTTP API defined by api/openapi.yaml.
api/gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
api/middleware
Package middleware provides the HTTP middleware shared by every route on the Schedularr API server: request-id propagation, structured request logging, panic recovery, and bearer-token authentication.
Package middleware provides the HTTP middleware shared by every route on the Schedularr API server: request-id propagation, structured request logging, panic recovery, and bearer-token authentication.
blockio
Package blockio provides CUE-validated YAML import/export for scheduling blocks, plus first-run bootstrap of a static scheduler file into the block store (see Bootstrap in bootstrap.go).
Package blockio provides CUE-validated YAML import/export for scheduling blocks, plus first-run bootstrap of a static scheduler file into the block store (see Bootstrap in bootstrap.go).
cache
Package cache provides an in-memory caching mechanism for application data.
Package cache provides an in-memory caching mechanism for application data.
config
Package config provides configuration loading for Schedularr.
Package config provides configuration loading for Schedularr.
cueconfig
Package cueconfig provides CUE schema-based configuration validation, generation, and loading.
Package cueconfig provides CUE schema-based configuration validation, generation, and loading.
external/tunarr
Package tunarr provides a client for interacting with the Tunarr API.
Package tunarr provides a client for interacting with the Tunarr API.
httpclient
Package httpclient provides a shared HTTP client with retry logic and metrics instrumentation.
Package httpclient provides a shared HTTP client with retry logic and metrics instrumentation.
metrics
Package metrics provides Prometheus metrics instrumentation for Schedularr.
Package metrics provides Prometheus metrics instrumentation for Schedularr.
problem
Package problem defines the RFC 7807 problem+json error body shared by the Schedularr API's handlers (internal/api) and its HTTP middleware (internal/api/middleware).
Package problem defines the RFC 7807 problem+json error body shared by the Schedularr API's handlers (internal/api) and its HTTP middleware (internal/api/middleware).
scheduler
Package scheduler provides the core scheduling engine for Schedularr.
Package scheduler provides the core scheduling engine for Schedularr.
service
Package service hosts the schedule-generation workflow shared by the CLI (cmd/generate.go) and the HTTP API (internal/api/schedule.go): loading the active scheduling blocks, fetching available Tunarr content, running the scheduling engine over a time window, and -- when asked -- pushing the result to Tunarr and committing engine state.
Package service hosts the schedule-generation workflow shared by the CLI (cmd/generate.go) and the HTTP API (internal/api/schedule.go): loading the active scheduling blocks, fetching available Tunarr content, running the scheduling engine over a time window, and -- when asked -- pushing the result to Tunarr and committing engine state.
store
Package store provides persistence for scheduling state.
Package store provides persistence for scheduling state.
Package web embeds the Hugo-built site (web/public) into the schedularr binary.
Package web embeds the Hugo-built site (web/public) into the schedularr binary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL