Phase 9, part 6: background work shared safely between copies of the app

internal/jobs keeps named locks as leases in the database (schema 31:
locks, instances), taken with one conditional UPDATE on SQLite or Postgres,
renewed while the work runs and lapsing if its copy stops. Each background
loop's turn, sending an email, audits, discovery runs and imports run
under a lock; OAuth sign-ins under way are kept in the database. Copies
check in, and work marked running is recovered at start only when no
other copy is alive. Settings -> About lists the copies and work under
way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 07:56:47 -07:00
co-authored by Claude Opus 5.5
parent ba6114f367
commit c6c4c40600
18 changed files with 873 additions and 150 deletions
+3 -1
View File
@@ -371,7 +371,9 @@ func (s *Server) RunScheduler(ctx context.Context) {
tick := time.NewTicker(schedulerInterval)
defer tick.Stop()
for {
s.publishDue(ctx, time.Now())
s.jobDo(ctx, "scheduler", func(ctx context.Context) {
s.publishDue(ctx, time.Now())
})
select {
case <-ctx.Done():
return