feat: HTTP panel on :8000 with first admin setup

This commit is contained in:
orohi
2026-06-17 04:40:34 +03:00
parent f214aaa48b
commit 0f31c24bf9
14 changed files with 502 additions and 5 deletions
+24 -1
View File
@@ -2,13 +2,18 @@ package main
import (
"context"
"errors"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"time"
"github.com/panelhosting/panel/internal/config"
"github.com/panelhosting/panel/internal/database"
"github.com/panelhosting/panel/internal/server"
)
func main() {
@@ -26,6 +31,24 @@ func main() {
}
defer pool.Close()
log.Println("panel database ready (API coming soon)")
addr := fmt.Sprintf(":%s", cfg.HTTPPort)
srv, err := server.New(pool, addr)
if err != nil {
log.Fatal(err)
}
go func() {
if err := srv.Start(); err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Fatal(err)
}
}()
<-ctx.Done()
log.Println("shutting down...")
shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if err := srv.Shutdown(shutdownCtx); err != nil {
log.Fatal(err)
}
}