photoprism/internal/commands/commands.go

42 lines
813 B
Go
Raw Normal View History

/*
This package contains commands and flags used by the photoprism application.
2018-11-06 19:02:03 +01:00
Additional information concerning the command-line interface can be found in our Developer Guide:
https://github.com/photoprism/photoprism/wiki/Commands
*/
package commands
2019-07-03 19:56:47 +02:00
import (
"os"
"syscall"
"github.com/photoprism/photoprism/internal/util"
"github.com/sevlyar/go-daemon"
"github.com/sirupsen/logrus"
)
var log *logrus.Logger
func init() {
log = logrus.StandardLogger()
}
2019-07-03 19:56:47 +02:00
func childAlreadyRunning(filePath string) (pid int, running bool) {
if !util.Exists(filePath) {
return pid, false
}
pid, err := daemon.ReadPidFile(filePath)
if err != nil {
return pid, false
}
process, err := os.FindProcess(int(pid))
if err != nil {
return pid, false
}
return pid, process.Signal(syscall.Signal(0)) == nil
}