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:
@@ -758,3 +758,19 @@ func TestAboutPage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Settings → About lists this copy of the app, and work under way.
|
||||
func TestAboutRunning(t *testing.T) {
|
||||
s, h := newTestServer(t, nil)
|
||||
_, release, err := s.jobs().TryLock(context.Background(), "job:seo")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer release()
|
||||
body := do(h, "GET", "/settings/about", nil, nil).Body.String()
|
||||
for _, want := range []string{"<code>" + s.jobs().ID() + "</code> <span class=\"muted\">(this one)</span>", "<code>job:seo</code>"} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("no %q", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user