Skip to content

Commit

Permalink
Loader: fix "dispatcher is shutdown" error when setting up SSH tunnel (
Browse files Browse the repository at this point in the history
…close #1278)
  • Loading branch information
istreeter committed Jun 27, 2023
1 parent a8f3ae4 commit f1e3c71
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ object SSH {
inner: Transactor.Aux[F, A]
): Resource[F, Transactor.Aux[F, A]] =
for {
_ <- Resource.eval(configureLogging)
dispatcher <- Dispatcher.sequential[F](await = false)
_ <- Resource.eval(configureLogging(dispatcher))
identity <- Resource.eval(getIdentity(config))
hs <- Hotswap.create[F, Session]
ref <- Resource.eval(Ref.of[F, Option[Session]](None))
Expand Down Expand Up @@ -79,9 +80,9 @@ object SSH {
}
}

def configureLogging[F[_]: Async]: F[Unit] =
Dispatcher.parallel[F].use { dispatcher =>
Sync[F].delay(JSch.setLogger(new JLogger {
def configureLogging[F[_]: Sync](dispatcher: Dispatcher[F]): F[Unit] =
Sync[F].delay {
JSch.setLogger(new JLogger {
override def isEnabled(level: Int): Boolean = true

override def log(level: Int, message: String): Unit = dispatcher.unsafeRunSync(level match {
Expand All @@ -92,7 +93,7 @@ object SSH {
case JLogger.FATAL => Logger[F].error("JCsh: " + message)
case _ => Logger[F].warn("NO LOG LEVEL JCsh: " + message)
})
}))
})
}

/** Convert pure tunnel configuration to configuration with actual key and passphrase */
Expand Down

0 comments on commit f1e3c71

Please sign in to comment.