Добавить установщик, проверку версий и инструкцию деплоя на сервер.

Интерактивная настройка домена и БД, эндпоинты /health и /version,
скрипты install/check для Linux и Windows.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shop
2026-05-16 17:17:19 +03:00
parent 448cf2a465
commit a3d3721724
17 changed files with 784 additions and 23 deletions
+16 -1
View File
@@ -11,10 +11,12 @@ import (
"syscall"
"time"
"shop/internal/check"
"shop/internal/config"
"shop/internal/database"
"shop/internal/handlers"
"shop/internal/repository"
"shop/internal/version"
"shop/internal/web"
)
@@ -31,6 +33,17 @@ func main() {
}
defer pool.Close()
startupReport, err := check.WithDatabase(ctx, pool)
if err != nil {
log.Fatalf("version check: %v", err)
}
for _, it := range startupReport.Items {
if it.Name == "postgresql" && it.Status == check.StatusWarn {
log.Printf("warning: %s — %s", it.Name, it.Detail)
}
}
log.Printf("ShopNova %s | Go %s | PostgreSQL check OK", version.AppVersion, version.GoRuntime())
tmpl, err := loadTemplates()
if err != nil {
log.Fatalf("templates: %v", err)
@@ -38,6 +51,7 @@ func main() {
products := repository.NewProductRepository(pool)
home := handlers.NewHomeHandler(products, tmpl)
health := handlers.NewHealthHandler(pool)
staticSub, err := fs.Sub(web.StaticFS, "static")
if err != nil {
@@ -46,7 +60,8 @@ func main() {
mux := http.NewServeMux()
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSub))))
mux.Handle("GET /health", http.HandlerFunc(handlers.Health))
mux.HandleFunc("GET /health", health.Health)
mux.HandleFunc("GET /version", health.Version)
mux.Handle("GET /", home)
srv := &http.Server{