Phase 13, part 9: running at scale, and the proof
The multi-tenant edition starts. compose.multi.yaml runs several copies behind Caddy, with the managed Postgres and Garage outside. A test walks every page and fragment, with ids filled in, and every MCP tool, as one team, and none shows another team's data or changes it; another has three copies share six teams' work, each team's turn once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+22
-3
@@ -241,8 +241,11 @@ func run(log *slog.Logger) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
multi := cfg.Edition == config.Multi
|
||||
if !alone {
|
||||
log.Info("jobs: other copies of Supermarket are running; work they have under way is left to them")
|
||||
} else if multi {
|
||||
// Each team's, once the teams are open (below).
|
||||
} else if n, err := content.RecoverInterrupted(database); err != nil {
|
||||
return err
|
||||
} else if n > 0 {
|
||||
@@ -301,13 +304,17 @@ func run(log *slog.Logger) error {
|
||||
|
||||
// The import never stops the app: a bad old file is reported on the
|
||||
// overview page instead.
|
||||
status, importErr := legacy.Import(database, sec, filepath.Join(dataDir, "import"))
|
||||
var status *legacy.Status
|
||||
var importErr error
|
||||
if !multi {
|
||||
status, importErr = legacy.Import(database, sec, filepath.Join(dataDir, "import"))
|
||||
}
|
||||
if importErr != nil {
|
||||
log.Error("importing the old app's data", "err", importErr)
|
||||
} else if status != nil {
|
||||
log.Info("imported the old app's data", "summary", strings.Join(status.Summary, "; "))
|
||||
}
|
||||
if status == nil && importErr == nil {
|
||||
if status == nil && importErr == nil && !multi {
|
||||
status, _ = legacy.LoadStatus(database)
|
||||
}
|
||||
|
||||
@@ -328,6 +335,18 @@ func run(log *slog.Logger) error {
|
||||
ImportStatus: status,
|
||||
ImportErr: importErr,
|
||||
}
|
||||
// The multi-tenant edition: each team's data in its own schema.
|
||||
if multi {
|
||||
teams, err := database.Teams()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer teams.Close()
|
||||
srv.Teams, srv.Platform = teams, database
|
||||
if alone {
|
||||
srv.RecoverTeams(context.Background())
|
||||
}
|
||||
}
|
||||
// Agents reach /mcp with their keys. On the local edition, mcp-token is
|
||||
// the key of the built-in Hermes agent.
|
||||
srv.MCP = mcpserver.Handler(database, version, srv.AgentAuth, srv.AgentTools)
|
||||
@@ -342,7 +361,7 @@ func run(log *slog.Logger) error {
|
||||
}
|
||||
|
||||
// A new server has no owner yet: a link to create one.
|
||||
if cfg.Edition != config.Local {
|
||||
if cfg.Edition == config.Server {
|
||||
if link, err := setupLink(database, publicURL); err != nil {
|
||||
return err
|
||||
} else if link != "" {
|
||||
|
||||
Reference in New Issue
Block a user