Code clean-up in commands

This commit is contained in:
Michael Mayer 2019-07-03 19:56:47 +02:00
parent 909b1d9f8a
commit 10269c6f6c
2 changed files with 27 additions and 19 deletions

View file

@ -7,10 +7,35 @@ https://github.com/photoprism/photoprism/wiki/Commands
*/
package commands
import "github.com/sirupsen/logrus"
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()
}
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
}

View file

@ -73,6 +73,7 @@ func startAction(ctx *cli.Context) error {
if err := conf.Init(cctx); err != nil {
log.Fatal(err)
}
conf.MigrateDb()
dctx := new(daemon.Context)
@ -129,21 +130,3 @@ func startAction(ctx *cli.Context) error {
return nil
}
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
}