/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
internal/server/process/pid.go
27 строк
542 B
Michael Mayer
Server: Move process handling and shutdown to separate package #4767
04 фев 2025, 21:05
04 фев 2025, 21:05
ae5f352
Код
Авторство
О чём код?
package process import ( "fmt" "os" "path/filepath" "github.com/photoprism/photoprism/pkg/fs" ) // ID is the process ID under which the server is running. var ID = os.Getpid() // WritePID writes the process ID to a file, if specified. func WritePID(fileName string) error { if fileName == "" { return nil } if pidDir := filepath.Dir(fileName); !fs.Writable(pidDir) { return fmt.Errorf("%s is not writable", pidDir) } else if err := fs.WriteString(fileName, fmt.Sprintf("%d", ID)); err != nil { return err } return nil }