mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
32 lines
460 B
Go
32 lines
460 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"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) {
|
|
if sets.ReadOnly {
|
|
c.Status(http.StatusForbidden)
|
|
return
|
|
}
|
|
c.Status(200)
|
|
go func() {
|
|
time.Sleep(1000)
|
|
torr.Shutdown()
|
|
}()
|
|
}
|