/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
internal/commands/stop.go
65 строк
1 KB
Michael Mayer
Commands: Prevent config command tests from polluting the originals directory
30 май 2026, 19:13
30 май 2026, 19:13
89a0bd7
Код
Авторство
О чём код?
package commands import ( "errors" "os" "syscall" "github.com/sevlyar/go-daemon" "github.com/urfave/cli/v2" "github.com/photoprism/photoprism/pkg/clean" ) // StopCommand configures the command name, flags, and action. var StopCommand = &cli.Command{ Name: "stop", Aliases: []string{"down"}, Usage: "Stops the Web server in daemon mode", Action: stopAction, } // stopAction stops the daemon if it is running. func stopAction(ctx *cli.Context) error { conf, err := InitCoreConfig(ctx, false) if err != nil { log.Debug(err) } log.Infof("looking for pid in %s", clean.Log(conf.PIDFilename())) dcxt := new(daemon.Context) dcxt.PidFileName = conf.PIDFilename() child, err := dcxt.Search() if err != nil { if errors.Is(err, os.ErrNotExist) { log.Info("daemon is not running") return nil } return err } if child == nil { log.Info("daemon is not running") return nil } err = child.Signal(syscall.SIGTERM) if err != nil { return err } st, err := child.Wait() if err != nil { log.Info("daemon exited successfully") return nil } log.Infof("daemon[%v] exited[%v]? successfully[%v]?\n", st.Pid(), st.Exited(), st.Success()) return nil }