wip (apply)

This commit is contained in:
2025-10-20 01:35:32 +02:00
parent 8ca8918966
commit a95dd4f3e0
14 changed files with 354 additions and 15 deletions

View File

@@ -1,19 +1,37 @@
package main
import (
"flag"
"fmt"
"log/slog"
"mirror-sync/cmd/server/api"
"mirror-sync/cmd/server/core/storage"
"mirror-sync/pkg/constants"
"os"
"runtime"
)
func main() {
var dbPath string
flag.StringVar(&dbPath, "db-path", "/var/lib/mirror-sync/data.db", "path to the sqlite database")
flag.Parse()
fmt.Printf("mirror-sync daemon -- v%s.%s.%s\n\n", constants.Version, runtime.GOOS, runtime.GOARCH)
s := api.NewServer(8080)
data, err := storage.OpenDB(dbPath)
if err != nil {
fmt.Fprintln(os.Stderr, "failed to start server:", err.Error())
os.Exit(1)
}
fmt.Println("daemon listening to :8080")
if err := data.Migrate(); err != nil {
fmt.Fprintln(os.Stderr, "failed to start server:", err.Error())
os.Exit(1)
}
s := api.NewServer(data, 8080)
slog.Info("daemon listening to :8080")
if err := s.Server.ListenAndServe(); err != nil {
fmt.Fprintln(os.Stderr, "failed to start server:", err.Error())
os.Exit(1)