Move share & sync to workers package

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-04-06 09:41:42 +02:00
parent aa220a06fe
commit ae5b6b759e
4 changed files with 20 additions and 12 deletions
internal

View file

@ -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()

View file

@ -1,4 +1,4 @@
package photoprism
package workers
import (
"fmt"

View file

@ -1,4 +1,4 @@
package photoprism
package workers
import (
"fmt"

View file

@ -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
}