Добавить установщик, проверку версий и инструкцию деплоя на сервер.
Интерактивная настройка домена и БД, эндпоинты /health и /version, скрипты install/check для Linux и Windows. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+16
-1
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user