Skip to content

Commit

Permalink
Updater check period configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
jendakol committed Dec 10, 2018
1 parent 5c09a4c commit 9e65aff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/updater/Updater.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.util.concurrent.atomic.AtomicBoolean

import better.files.File
import com.typesafe.scalalogging.StrictLogging
import javax.inject.{Inject, Singleton}
import javax.inject.{Inject, Named, Singleton}
import lib.App._
import lib.AppException.UpdateException
import monix.execution.{Cancelable, Scheduler}
Expand All @@ -14,13 +14,16 @@ import scala.concurrent.duration._
import scala.util.control.NonFatal

@Singleton
class Updater @Inject()(connector: GithubConnector, serviceUpdater: ServiceUpdater)(implicit scheduler: Scheduler) extends StrictLogging {
class Updater @Inject()(connector: GithubConnector,
serviceUpdater: ServiceUpdater,
@Named("updaterCheckPeriod") checkPeriod: FiniteDuration)(implicit scheduler: Scheduler)
extends StrictLogging {
private val updateRunning = new AtomicBoolean(false)

def start: Cancelable = {
logger.info("Started updates checker")

scheduler.scheduleAtFixedRate(1.seconds, 10.seconds) {
scheduler.scheduleAtFixedRate(1.seconds, checkPeriod) {
connector.checkUpdate
.flatMap {
case Some(rel) =>
Expand Down
1 change: 1 addition & 0 deletions conf/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fileHandler {

updater {
releasesUrl = "https://github.com/jendakol/rbackup-scala-client/releases"
checkPeriod = 1 minute
}

sentry {
Expand Down

0 comments on commit 9e65aff

Please sign in to comment.