diff --git a/internal/commands/commands.go b/internal/commands/commands.go index 5e2db716f..d4c9ee14c 100644 --- a/internal/commands/commands.go +++ b/internal/commands/commands.go @@ -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 +} diff --git a/internal/commands/start.go b/internal/commands/start.go index cd797a3eb..67ef961a1 100644 --- a/internal/commands/start.go +++ b/internal/commands/start.go @@ -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 -}