Реализовать lab3 в общем Helm-релизе с Traefik, TLS и HPA
This commit is contained in:
+23
-1
@@ -1,7 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab3/internal/config"
|
||||
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab3/internal/store/postgres"
|
||||
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
@@ -12,8 +17,25 @@ func run(args []string) error {
|
||||
fx.New(CreateApp()).Run()
|
||||
return nil
|
||||
}
|
||||
if len(args) == 1 && args[0] == "migrate" {
|
||||
return migrate()
|
||||
}
|
||||
if len(args) == 1 && args[0] == "healthcheck" {
|
||||
return healthcheck()
|
||||
}
|
||||
return fmt.Errorf("usage: server [healthcheck]")
|
||||
return fmt.Errorf("usage: server [healthcheck|migrate]")
|
||||
}
|
||||
|
||||
// migrate applies versioned DDL once from an operator job, independently of the API.
|
||||
func migrate() error {
|
||||
cfg, err := config.NewPersistence()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
database, err := postgres.New(postgres.Options{URL: cfg.DatabaseURL, MaxConnections: 1, Timeout: 30 * time.Second})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer database.Close()
|
||||
return database.Start(context.Background())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user