Files
TorrServerJellyfin/server/web/api/shutdown.go
nikk gitanes b44493c6c9 remove qiwi from donate links and fix ts icon
also we have a reason
2024-06-12 22:46:50 +03:00

34 lines
551 B
Go

package api
import (
"net/http"
"strings"
"time"
sets "server/settings"
"server/torr"
"github.com/gin-gonic/gin"
)
// shutdown godoc
// @Summary Shuts down server
// @Description Gracefully shuts down server after 1 second.
//
// @Tags API
//
// @Success 200
// @Router /shutdown [get]
func shutdown(c *gin.Context) {
reasonStr := strings.ReplaceAll(c.Param("reason"), `/`, "")
if sets.ReadOnly && reasonStr == "" {
c.Status(http.StatusForbidden)
return
}
c.Status(200)
go func() {
time.Sleep(1000)
torr.Shutdown()
}()
}