first working version

This commit is contained in:
2025-10-28 19:22:21 +01:00
parent 9406ffda01
commit 4a3fe068a3
9 changed files with 400 additions and 55 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"log/slog"
"mirror-sync/cmd/server/api"
cronruntime "mirror-sync/cmd/server/core/runtime"
"mirror-sync/cmd/server/core/storage"
"mirror-sync/pkg/constants"
"os"
@@ -29,7 +30,24 @@ func main() {
os.Exit(1)
}
s := api.NewServer(data, 8080)
// runtime
prs, err := data.List()
if err != nil {
fmt.Fprintln(os.Stderr, "failed to start server:", err.Error())
os.Exit(1)
}
scheduler, err := cronruntime.New(prs)
if err != nil {
fmt.Fprintln(os.Stderr, "failed to start server:", err.Error())
os.Exit(1)
}
go scheduler.Run()
slog.Info("daemon scheduler is running")
// api
s := api.NewServer(data, scheduler, 8080)
slog.Info("daemon listening to :8080")
if err := s.Server.ListenAndServe(); err != nil {