mirror of
https://github.com/photoprism/photoprism.git
synced 2025-10-05 16:57:17 +08:00

These changes allow to configure the computer vision models through an optional vision.yml configuration file. Note that the API endpoints are not yet functional and require further work. Signed-off-by: Michael Mayer <michael@photoprism.app>
35 lines
909 B
Go
35 lines
909 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/photoprism/photoprism/internal/auth/acl"
|
|
"github.com/photoprism/photoprism/internal/photoprism/get"
|
|
"github.com/photoprism/photoprism/internal/server/process"
|
|
)
|
|
|
|
// StopServer initiates a server restart if the user is authorized.
|
|
//
|
|
// POST /api/v1/server/stop
|
|
func StopServer(router *gin.RouterGroup) {
|
|
router.POST("/server/stop", func(c *gin.Context) {
|
|
s := Auth(c, acl.ResourceConfig, acl.ActionManage)
|
|
conf := get.Config()
|
|
|
|
// Abort if permission is not granted.
|
|
if s.Invalid() || conf.Public() || conf.DisableSettings() || conf.DisableRestart() {
|
|
AbortForbidden(c)
|
|
return
|
|
}
|
|
|
|
// Trigger restart.
|
|
//
|
|
// Note that this requires an entrypoint script or other process to
|
|
// spawns a new instance when the server exists with status code 1.
|
|
c.JSON(http.StatusOK, conf.Options())
|
|
process.Restart()
|
|
})
|
|
}
|