diff --git a/internal/commands/start.go b/internal/commands/start.go index 42a3250b0..7f19a0434 100644 --- a/internal/commands/start.go +++ b/internal/commands/start.go @@ -10,9 +10,9 @@ import ( "time" "github.com/photoprism/photoprism/internal/config" - "github.com/photoprism/photoprism/internal/photoprism" "github.com/photoprism/photoprism/internal/server" "github.com/photoprism/photoprism/internal/service" + "github.com/photoprism/photoprism/internal/workers" "github.com/photoprism/photoprism/pkg/fs" "github.com/sevlyar/go-daemon" "github.com/urfave/cli" @@ -118,15 +118,18 @@ func startAction(ctx *cli.Context) error { // start web server go server.Start(cctx, conf) - // start share & sync service workers - stop := photoprism.ServiceWorkers(conf) + // start share & sync workers + workers.Start(conf) // set up proper shutdown of daemon and web server quit := make(chan os.Signal) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) <-quit - stop <- true + + // stop share & sync workers + workers.Stop() + log.Info("shutting down...") conf.Shutdown() cancel() diff --git a/internal/photoprism/share.go b/internal/workers/share.go similarity index 99% rename from internal/photoprism/share.go rename to internal/workers/share.go index a80ac1a3e..292574a21 100644 --- a/internal/photoprism/share.go +++ b/internal/workers/share.go @@ -1,4 +1,4 @@ -package photoprism +package workers import ( "fmt" diff --git a/internal/photoprism/sync.go b/internal/workers/sync.go similarity index 99% rename from internal/photoprism/sync.go rename to internal/workers/sync.go index ea01f11f8..607d44bf8 100644 --- a/internal/photoprism/sync.go +++ b/internal/workers/sync.go @@ -1,4 +1,4 @@ -package photoprism +package workers import ( "fmt" diff --git a/internal/photoprism/service_workers.go b/internal/workers/workers.go similarity index 74% rename from internal/photoprism/service_workers.go rename to internal/workers/workers.go index d16dafa3a..29bd4aa09 100644 --- a/internal/photoprism/service_workers.go +++ b/internal/workers/workers.go @@ -1,15 +1,18 @@ -package photoprism +package workers import ( "time" "github.com/photoprism/photoprism/internal/config" + "github.com/photoprism/photoprism/internal/event" "github.com/photoprism/photoprism/internal/mutex" ) -func ServiceWorkers(conf *config.Config) chan bool { - ticker := time.NewTicker(1 * time.Minute) // TODO - stop := make(chan bool, 1) +var log = event.Log +var stop = make(chan bool, 1) + +func Start(conf *config.Config) { + ticker := time.NewTicker(5 * time.Minute) // TODO go func() { for { @@ -43,6 +46,8 @@ func ServiceWorkers(conf *config.Config) chan bool { } } }() - - return stop +} + +func Stop() { + stop <- true }