mirror of
https://github.com/komari-monitor/komari.git
synced 2026-11-24 17:10:54 +00:00
- Create ./data/plugin-data directory during bootstrap for plugin-owned persistent storage. - Document ExtraRoots and StorageDir in jsruntime README, including __storageDir__ global injection. - Drop Preview field from plugin market API and its validation as no longer used.
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/komari-monitor/komari/database/dbcore"
|
|
"github.com/komari-monitor/komari/internal/config"
|
|
"github.com/komari-monitor/komari/utils"
|
|
)
|
|
|
|
// Bootstrap initializes the data directory, primary database, and settings.
|
|
func (a *App) Bootstrap() error {
|
|
if err := os.MkdirAll("./data/theme", os.ModePerm); err != nil {
|
|
return fmt.Errorf("failed to create theme directory: %w", err)
|
|
}
|
|
if err := os.MkdirAll("./data/plugin", os.ModePerm); err != nil {
|
|
return fmt.Errorf("failed to create plugin directory: %w", err)
|
|
}
|
|
if err := os.MkdirAll("./data/plugin-data", os.ModePerm); err != nil {
|
|
return fmt.Errorf("failed to create plugin storage directory: %w", err)
|
|
}
|
|
|
|
dbcore.SetVersionID(utils.CurrentVersion + "-" + utils.VersionHash)
|
|
if err := dbcore.Initialize(); err != nil {
|
|
return fmt.Errorf("failed to initialize database: %w", err)
|
|
}
|
|
a.dbReady = true
|
|
a.addCleanup("database", func(context.Context) error { return dbcore.Close() })
|
|
|
|
gin.SetMode(gin.ReleaseMode)
|
|
settings, err := config.GetManyAs[config.Settings]()
|
|
if err != nil {
|
|
return fmt.Errorf("failed to load settings: %w", err)
|
|
}
|
|
a.settings = settings
|
|
return nil
|
|
}
|