40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"eden-server/internal/api"
|
|
"eden-server/internal/database"
|
|
"eden-server/internal/runtime"
|
|
"log/slog"
|
|
"os"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func main() {
|
|
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 := 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.Error("failed to ensure the operating environment", "error", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// initiating the database connection for which we safe things
|
|
slog.Info("kicking off database connection")
|
|
db, err := database.KickoffDatabase()
|
|
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)
|
|
}
|