Skip to content

Scheduled tasks and automation #217

@filthyrake

Description

@filthyrake

Summary

Add scheduled task system for automated maintenance and workflows.

Current State

No scheduled task system. Maintenance tasks (archive cleanup) rely on ad-hoc triggers.

Proposed Features

Built-in Scheduled Tasks

  • Archive Cleanup: Permanently delete expired archived videos
  • Analytics Aggregation: Pre-compute daily/weekly analytics
  • Stale Job Recovery: Already exists, formalize as scheduled task
  • Worker Health Check: Mark offline workers, cleanup dead sessions
  • Storage Cleanup: Remove orphaned files

User-Configurable Schedules

  • Schedule video publication (future publish date)
  • Schedule video archival/deletion
  • Schedule transcoding during off-peak hours

Task Framework

  • Cron-like scheduling syntax
  • Background task execution
  • Task history and logging
  • Manual task trigger

Database Schema

CREATE TABLE scheduled_tasks (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  schedule TEXT NOT NULL,  -- cron expression
  task_type TEXT NOT NULL,
  config TEXT,  -- JSON configuration
  enabled BOOLEAN DEFAULT true,
  last_run_at TIMESTAMP,
  next_run_at TIMESTAMP,
  last_status TEXT
);

CREATE TABLE task_history (
  id TEXT PRIMARY KEY,
  task_id TEXT REFERENCES scheduled_tasks(id),
  started_at TIMESTAMP,
  completed_at TIMESTAMP,
  status TEXT,
  result TEXT
);

CLI Commands

vlog task list                       # List scheduled tasks
vlog task run <task-name>            # Run task manually
vlog task enable/disable <task-name> # Toggle task
vlog task history <task-name>        # View task history

Implementation Options

  • APScheduler (Python scheduling library)
  • Celery Beat (if using Celery for task queue)
  • Simple cron-triggered CLI commands

Priority

Medium - improves operational automation

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmaintenanceMaintenance and cleanup tasks

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions