Skip to content

Commit

Permalink
Avoid going in an endless loop
Browse files Browse the repository at this point in the history
  • Loading branch information
eikek committed Jan 30, 2024
1 parent 7679716 commit 3040ff6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion project/RedisServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ class RedisServer(module: String, port: Int) {
println(s"Starting Redis container for '$module' from '$image' image")
startContainer()
var rc = 1
while (rc != 0) {
val maxTries = 500
var counter = 0
while (rc != 0 && counter < maxTries) {
counter += 1
Thread.sleep(500)
rc = Process(isReadyCmd).!
if (rc == 0) println(s"Redis container for '$module' started on port $port")
else println(s"IsReadyCmd returned $rc")
}
if (rc != 0) sys.error(s"Redis container for '$module' could not be started on port $port")
}
}

Expand Down
6 changes: 5 additions & 1 deletion project/SolrServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,15 @@ class SolrServer(module: String, port: Int) {

private def waitForCoresToBeReady(): Unit = {
var rc = 1
while (rc != 0) {
val maxTries = 500
var counter = 0
while (rc != 0 && counter < maxTries) {
counter += 1
Thread.sleep(500)
rc = checkCoresReady
if (rc == 0) println(s"Solr container for '$module' ready on port $port")
}
if (rc != 0) sys.error("Solr container for '$module' could not be started")
}

private def checkCoresReady =
Expand Down

0 comments on commit 3040ff6

Please sign in to comment.