feat: add new features such as database watchdog
This commit is contained in:
+12
-9
@@ -6,11 +6,10 @@ import (
|
||||
"eden-server/internal/runtime"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// configure the logger so we have nice json
|
||||
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
|
||||
slog.SetDefault(logger)
|
||||
|
||||
@@ -19,21 +18,25 @@ func main() {
|
||||
env := runtime.GrabEnvironment()
|
||||
|
||||
// checking directories to ensure its expected environment is ready
|
||||
slog.Info("ensuring operating environment")
|
||||
if err := runtime.EnsureOperation(env.WorkDir); err != nil {
|
||||
slog.Info("auditing operating environment")
|
||||
if err := runtime.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()
|
||||
db, err := database.KickoffDatabase(env.DataDirectory)
|
||||
if err != nil {
|
||||
slog.Error("failed to initiate a database connection")
|
||||
}
|
||||
|
||||
// get ready to kick off the http api
|
||||
slog.Info("kicking off http api, letting gin take over")
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
api.KickoffApi(env, db)
|
||||
slog.Info("kicking off database watchdog", "watch_interval", env.WatchInterval)
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user