This commit is contained in:
parent
56e8c75ee9
commit
f2afc2a50c
|
|
@ -41,6 +41,8 @@ RUN apt-get update && apt-get install -y \
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
COPY --from=builder /app/license-server .
|
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
|
EXPOSE 13579
|
||||||
|
|
||||||
CMD ["./license-server"]
|
CMD ["./license-server"]
|
||||||
|
|
|
||||||
9
main.go
9
main.go
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"license-server/license"
|
"license-server/license"
|
||||||
"license-server/storage"
|
"license-server/storage"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
@ -12,6 +13,14 @@ func main() {
|
||||||
license.InitCrypto(db)
|
license.InitCrypto(db)
|
||||||
app := fiber.New()
|
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/generate", license.GenerateLicenseHandler(db))
|
||||||
app.Post("/api/license/activate", license.ActivateLicenseHandler(db))
|
app.Post("/api/license/activate", license.ActivateLicenseHandler(db))
|
||||||
app.Post("/api/license/validate", license.ValidateLicenseHandler(db))
|
app.Post("/api/license/validate", license.ValidateLicenseHandler(db))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue