Files
orbits/cmd/server/main.go
T
2026-04-22 15:26:59 +02:00

45 lines
1.3 KiB
Go

package main
import (
"eden-server/internal/api"
"eden-server/internal/database"
"eden-server/internal/utility"
"log/slog"
"os"
)
func main() {
// configure the logger so we have nice json
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
slog.SetDefault(logger)
// grab the environment variables from the runtime environment
slog.Info("grabbing environment variables")
env := utility.GrabEnvironment()
// TO DO, allow cmd args parsing
// checking directories to ensure its expected environment is ready
slog.Info("auditing operating environment")
if err := utility.EnsureOperation(env.DataDirectory); err != nil {
slog.Error("failed to ensure the operating environment", "error", err)
os.Exit(1)
}
slog.Info("finished audit of environment")
// initiating the database connection for which we safe things
slog.Info("kicking off database connection")
db, err := database.KickoffDatabase(env.DataDirectory)
if err != nil {
slog.Error("failed to initiate a database connection", "error", err)
os.Exit(1)
}
slog.Info("kicking off database watchdog", "watch_interval", env.WatchdogInterval)
database.KickoffDatabaseWatchdog(env, db)
// TO DO make gin log as json
// get ready to kick off the http api with Vue frontend
slog.Info("kicking off http api backend")
api.KickoffApi(logger, env, db)
}