Replaced legacy `*.orly` module imports with `next.orly.dev/pkg` paths across the codebase for consistency. Removed legacy `go.mod` files from sub-packages, consolidating dependency management. Added Dockerfiles and configurations for benchmarking environments.
55 lines
1007 B
Go
55 lines
1007 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
|
|
"lol.mleku.dev/chk"
|
|
"lol.mleku.dev/log"
|
|
"next.orly.dev/app"
|
|
"next.orly.dev/app/config"
|
|
acl "next.orly.dev/pkg/acl"
|
|
database "next.orly.dev/pkg/database"
|
|
"next.orly.dev/pkg/version"
|
|
)
|
|
|
|
func main() {
|
|
var err error
|
|
var cfg *config.C
|
|
if cfg, err = config.New(); chk.T(err) {
|
|
}
|
|
log.I.F("starting %s %s", cfg.AppName, version.V)
|
|
startProfiler(cfg.Pprof)
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
var db *database.D
|
|
if db, err = database.New(
|
|
ctx, cancel, cfg.DataDir, cfg.DBLogLevel,
|
|
); chk.E(err) {
|
|
os.Exit(1)
|
|
}
|
|
acl.Registry.Active.Store(cfg.ACLMode)
|
|
if err = acl.Registry.Configure(cfg, db, ctx); chk.E(err) {
|
|
os.Exit(1)
|
|
}
|
|
acl.Registry.Syncer()
|
|
quit := app.Run(ctx, cfg, db)
|
|
sigs := make(chan os.Signal, 1)
|
|
signal.Notify(sigs, os.Interrupt)
|
|
for {
|
|
select {
|
|
case <-sigs:
|
|
fmt.Printf("\r")
|
|
cancel()
|
|
chk.E(db.Close())
|
|
return
|
|
case <-quit:
|
|
cancel()
|
|
chk.E(db.Close())
|
|
return
|
|
}
|
|
}
|
|
|
|
}
|