feat: make watchdog itself configurable

This commit is contained in:
DaanSelen
2026-04-22 16:29:07 +02:00
parent ec3a996d6a
commit fa832bd1e0
12 changed files with 59 additions and 53 deletions
+5 -4
View File
@@ -1,7 +1,7 @@
package database
import (
"eden-server/internal/utility"
"orbits-server/internal/utility"
"path/filepath"
"time"
@@ -13,7 +13,7 @@ import (
//var watchdogStop = make(chan struct{})
func KickoffDatabase(workDir string) (*gorm.DB, error) {
dbLoc := filepath.Join(workDir, "garden.db")
dbLoc := filepath.Join(workDir, "station.db")
db, err := gorm.Open(sqlite.Open(dbLoc), &gorm.Config{
Logger: logger.Discard, // disable gorm logging since its not slog (yet)
TranslateError: true,
@@ -24,7 +24,7 @@ func KickoffDatabase(workDir string) (*gorm.DB, error) {
// try to use GORM automigrate if the schema changes
if err := db.AutoMigrate(
&State{},
&Command{},
&Device{},
&File{},
); err != nil {
@@ -32,8 +32,9 @@ func KickoffDatabase(workDir string) (*gorm.DB, error) {
}
// create the first row if it does not exist yet
if err := db.FirstOrCreate(&State{}, State{
if err := db.FirstOrCreate(&Command{}, Command{
ID: 0,
State: "idle",
MediaType: Unspecified,
}).Error; err != nil {
return nil, err