Skip to content

Commit

Permalink
Stopping spark at the end of the job can be turned off
Browse files Browse the repository at this point in the history
  • Loading branch information
leobenkel committed May 22, 2020
1 parent 9a0da18 commit 75173d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions Library/src/main/scala/com/leobenkel/zparkio/ZparkioApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ trait ZparkioApp[C <: CLA.Service, ENV <: ZparkioApp.ZPEnv[C] with Logger, OUTPU
} yield { makeEnvironment(cliService, logger.log, sparkService) }
}

protected def stopSparkAtTheEnd: Boolean = true

protected def app(args: List[String]): ZIO[zio.ZEnv, Throwable, OUTPUT] = {
for {
env <- buildEnv(args)
Expand All @@ -72,8 +74,15 @@ trait ZparkioApp[C <: CLA.Service, ENV <: ZparkioApp.ZPEnv[C] with Logger, OUTPU
output <- runApp()
.provide(env)
.timeoutFail(ZparkioApplicationTimeoutException())(timedApplication)
_ = s.sparkContext.stop()
_ = s.stop()
_ <- if (stopSparkAtTheEnd) {
Task {
s.sparkContext.stop()
s.stop()
()
}
} else {
Task(())
}
} yield { output }
}

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.8.0
v0.8.2

0 comments on commit 75173d9

Please sign in to comment.