First commit, basic SQLite store, worker, and server

This commit is contained in:
Miloš Jovanović 2026-09-08 09:45:23 +02:00
commit baacf30c6d
7 changed files with 319 additions and 0 deletions

34
main.go Normal file
View file

@ -0,0 +1,34 @@
package main
import (
"log"
"net/http"
"os"
)
func main() {
secret := os.Getenv("WEBHOOK_SECRET")
if secret == "" {
log.Fatal("WEBHOOK_SECRET not set")
}
dbPath := os.Getenv("DB_PATH")
if dbPath == "" {
dbPath = "worker.db"
}
store, err := OpenStore(dbPath)
if err != nil {
log.Fatalf("opening store: %v", err)
}
// Any run still marked running belongs to a dead process.
if err := store.SweepStaleLocks(); err != nil {
log.Fatalf("sweeping stale locks: %v", err)
}
srv := NewServer(&fakeST{dept: "History", chapterID: 602}, store, secret)
log.Println("listening on :8080")
log.Fatal(http.ListenAndServe(":8080", srv.Routes()))
}