first working version
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user