This commit is contained in:
hailin 2025-06-17 23:06:58 +08:00
parent 56e8c75ee9
commit f2afc2a50c
2 changed files with 11 additions and 0 deletions

View File

@ -41,6 +41,8 @@ RUN apt-get update && apt-get install -y \
WORKDIR /root/
COPY --from=builder /app/license-server .
HEALTHCHECK --interval=60s --timeout=3s --start-period=10s --retries=3 CMD curl -f http://localhost:13579/api/health || exit 1
EXPOSE 13579
CMD ["./license-server"]

View File

@ -3,6 +3,7 @@ package main
import (
"license-server/license"
"license-server/storage"
"time"
"github.com/gofiber/fiber/v2"
)
@ -12,6 +13,14 @@ func main() {
license.InitCrypto(db)
app := fiber.New()
// --- 简单健康检查 ---
app.Get("/api/health", func(c *fiber.Ctx) error {
return c.JSON(fiber.Map{
"status": "ok",
"ts": time.Now().Unix(),
})
})
app.Post("/api/license/generate", license.GenerateLicenseHandler(db))
app.Post("/api/license/activate", license.ActivateLicenseHandler(db))
app.Post("/api/license/validate", license.ValidateLicenseHandler(db))