Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions cmd/maintmode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ func main() {
}
closer.Add(valkeyClient.Close)

// Owns the lifecycle signals: main marks start-up complete and flips drain
// on shutdown, the readiness handler only reads them. Keeps process-lifecycle
// state out of the HTTP layer.
starter := lifecycle.NewStarter()
drainer := lifecycle.NewDrainer()

// Started before the modules so liveness answers while they come up (the
// auth reloader blocks on its first snapshot); readiness holds 503 until
// MarkReady below, whatever order the modules initialize in.
startInfraServer(ctx, cfg, meta, db, starter, drainer, logger)

// Bootstrap application layers
stores, err := bootstrap.NewStores(cfg, db, valkeyClient)
if err != nil {
Expand All @@ -155,11 +166,7 @@ func main() {

startAPIServer(ctx, cfg, meta, services, valkeyClient, logger)

// Owns the drain signal: main flips it on shutdown, the readiness handler
// only reads it. Keeps process-lifecycle state out of the HTTP layer.
drainer := lifecycle.NewDrainer()

startInfraServer(ctx, cfg, meta, db, drainer, logger)
starter.MarkReady()

<-ctx.Done()
shutdown(context.WithoutCancel(ctx), drainer, cfg.Shutdown.DrainTimeoutOrDefault())
Expand Down Expand Up @@ -224,6 +231,7 @@ func startInfraServer(
cfg *config.AppConfig,
meta *buildmeta.AppBuildMeta,
db *sqlx.DB,
starter *lifecycle.Starter,
drainer *lifecycle.Drainer,
logger xlog.Logger,
) {
Expand Down Expand Up @@ -258,6 +266,7 @@ func startInfraServer(
// can still serve every request.
Checks: []infra.Check{{Name: "postgres", Probe: db.PingContext}},
Drainer: drainer,
Starter: starter,
Specs: []swaggerui.Spec{
{Name: buildmeta.MaintModeAppName, Content: docs.MaintmodeSpec},
// "auth" is the dropdown label for the auth API spec, not a per-binary
Expand Down
65 changes: 33 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ go 1.26.0
toolchain go1.26.9

require (
github.com/MicahParks/jwkset v0.11.3
github.com/MicahParks/keyfunc/v3 v3.8.2
github.com/MicahParks/jwkset v0.11.4
github.com/MicahParks/keyfunc/v3 v3.9.1
github.com/casbin/casbin/v3 v3.11.0
github.com/coreos/go-oidc/v3 v3.21.0
github.com/go-jet/jet/v2 v2.16.1
github.com/go-ozzo/ozzo-validation/v4 v4.4.1
github.com/go-ozzo/ozzo-validation/v4 v4.5.0
github.com/go-redis/redis_rate/v10 v10.0.1
github.com/go-telegram/bot v1.27.0
github.com/golang-jwt/jwt/v5 v5.3.1
Expand All @@ -19,21 +19,21 @@ require (
github.com/jellydator/ttlcache/v3 v3.4.1
github.com/jmoiron/sqlx v1.4.0
github.com/labstack/echo-otel/v5 v5.0.0
github.com/labstack/echo/v5 v5.4.0
github.com/labstack/echo/v5 v5.4.4
github.com/lib/pq v1.12.3
github.com/mattn/go-sqlite3 v1.14.52
github.com/oapi-codegen/runtime v1.7.0
github.com/oapi-codegen/runtime v1.8.0
github.com/redis/go-redis/v9 v9.23.0
github.com/ruko1202/goque v0.8.11
github.com/ruko1202/goque v0.12.3
github.com/ruko1202/swaggerui v0.5.0
github.com/ruko1202/xhttp v0.4.1
github.com/ruko1202/xhttp v0.5.1
github.com/ruko1202/xlog v0.5.1
github.com/samber/lo v1.53.0
github.com/slack-go/slack v0.30.1
github.com/slack-go/slack v0.34.0
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.12.1
github.com/tink-crypto/tink-go/v2 v2.8.0
github.com/tink-crypto/tink-go/v2 v2.9.0
github.com/wneessen/go-mail v0.8.1
go.opentelemetry.io/otel v1.47.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.47.0
Expand All @@ -44,46 +44,47 @@ require (
go.opentelemetry.io/otel/trace v1.47.0
go.uber.org/mock v0.6.0
go.uber.org/zap v1.28.0
golang.org/x/crypto v0.57.0
golang.org/x/crypto v0.58.0
golang.org/x/oauth2 v0.37.0
golang.org/x/sync v0.23.0
golang.org/x/text v0.42.0
golang.org/x/sync v0.24.0
golang.org/x/text v0.43.0
gopkg.in/yaml.v3 v3.0.1
)

require (
filippo.io/edwards25519 v1.2.0 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.10.4 // indirect
github.com/casbin/govaluate v1.10.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
github.com/go-jose/go-jose/v4 v4.1.8 // indirect
github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-sql-driver/mysql v1.10.0 // indirect
github.com/go-sql-driver/mysql v1.10.1 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/goccy/go-json v0.10.6 // indirect
github.com/goccy/go-json v0.12.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.33.0 // indirect
github.com/jackc/pgerrcode v0.0.0-20250907135507-afb5586c32a6 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.10.0 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jackc/pgx/v5 v5.12.0 // indirect
github.com/jackc/puddle/v2 v2.2.3 // indirect
github.com/labstack/echo-contrib/v5 v5.0.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pandatix/go-abnf v0.5.5 // indirect
github.com/panjf2000/ants/v2 v2.12.1 // indirect
github.com/pelletier/go-toml/v2 v2.4.2 // indirect
github.com/prometheus/client_golang v1.24.1 // indirect
github.com/pelletier/go-toml/v2 v2.4.3 // indirect
github.com/prometheus/client_golang v1.25.0 // indirect
github.com/prometheus/client_model v0.6.3 // indirect
github.com/prometheus/common v0.72.0 // indirect
github.com/prometheus/common v0.73.1 // indirect
github.com/prometheus/otlptranslator v1.0.0 // indirect
github.com/prometheus/procfs v0.22.0 // indirect
github.com/prometheus/procfs v0.23.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/spf13/afero v1.15.0 // indirect
Expand All @@ -92,15 +93,15 @@ require (
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect
go.opentelemetry.io/otel/log v1.47.0 // indirect
go.opentelemetry.io/proto/otlp v1.11.0 // indirect
go.opentelemetry.io/proto/otlp v1.11.1 // indirect
go.uber.org/atomic v1.12.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
golang.org/x/net v0.60.0 // indirect
golang.org/x/sys v0.48.0 // indirect
golang.org/x/time v0.15.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260928230214-8a89bd6388cc // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260928230214-8a89bd6388cc // indirect
google.golang.org/grpc v1.83.2 // indirect
go.yaml.in/yaml/v3 v3.0.6 // indirect
golang.org/x/net v0.62.0 // indirect
golang.org/x/sys v0.49.0 // indirect
golang.org/x/time v0.16.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20261026165753-2ffab32bce7e // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20261026165753-2ffab32bce7e // indirect
google.golang.org/grpc v1.85.0 // indirect
google.golang.org/protobuf v1.36.12 // indirect
)
Loading
Loading