Rework NativeProcessFactory.cmd to be Vector[String] (#5623)

* Rework NativeProcessFactory.cmd to be Vector[String]

* Fix eclair commands
This commit is contained in:
Chris Stewart 2024-07-18 06:15:40 -07:00 committed by GitHub
parent 4885bdb07d
commit 6b12bb515d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 31 additions and 19 deletions

View File

@ -15,7 +15,7 @@ trait NativeProcessFactory extends BitcoinSLogger {
private lazy val process: ProcessBuilder = scala.sys.process.Process(cmd)
/** The command to start the daemon on the underlying OS */
def cmd: String
def cmd: Vector[String]
def isAlive(): Boolean = {
processOpt match {

View File

@ -131,16 +131,16 @@ trait Client
def getDaemon: BitcoindInstance = instance
override lazy val cmd: String = {
override lazy val cmd: Vector[String] = {
instance match {
case _: BitcoindInstanceRemote =>
logger.warn(
s"Cannot start remote instance with local binary command. You've likely misconfigured something"
)
""
Vector.empty
case local: BitcoindInstanceLocal =>
val binaryPath = local.binary.getAbsolutePath
val cmd = List(
val cmd = Vector(
binaryPath,
"-datadir=" + local.datadir,
"-rpcport=" + instance.rpcUri.getPort,
@ -150,7 +150,7 @@ trait Client
s"starting bitcoind with datadir ${local.datadir} and binary path $binaryPath"
)
cmd.mkString(" ")
cmd
}
}

View File

@ -396,12 +396,17 @@ class CLightningRpcClient(val instance: CLightningInstanceLocal, binary: File)(
clightningCall[SendCustomMessageResult]("sendcustommsg", params)
}
override val cmd: String = {
override val cmd: Vector[String] = {
val logFileConf = instance.logFileOpt
.map(f => s"--log-file=${f.getAbsolutePath}")
.getOrElse("")
s"$binary --lightning-dir=${instance.datadir.toAbsolutePath} --rpc-file=${instance.rpcFile.getAbsolutePath} $logFileConf"
Vector(
binary.toString,
s"--lightning-dir=${instance.datadir.toAbsolutePath}",
s"--rpc-file=${instance.rpcFile.getAbsolutePath}",
logFileConf
)
}
override def start(): Future[CLightningRpcClient] = {

View File

@ -823,7 +823,7 @@ class EclairRpcClient(
// default to provided binary
case (Some(binary), _) =>
if (binary.exists) {
binary.toString
binary.toPath.toAbsolutePath.toString
} else {
throw new NoSuchFileException(
s"Given binary ($binary) does not exist!"
@ -855,12 +855,16 @@ class EclairRpcClient(
}
}
override def cmd: String = {
val logback = instance.logbackXmlPath
override def cmd: Vector[String] = {
val logbackOpt = instance.logbackXmlPath
.map(path => s"-Dlogback.configurationFile=$path")
.getOrElse("")
val cmd = {
s"${pathToEclairJar} -Declair.datadir=${instance.authCredentials.datadir.get} $logback"
val base = Vector(
pathToEclairJar,
s"-Declair.datadir=${instance.authCredentials.datadir.get}"
)
val cmd = logbackOpt match {
case Some(logback) => base.appended(logback)
case None => base
}
cmd
}

View File

@ -129,10 +129,13 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
}
/** The command to start the daemon on the underlying OS */
override def cmd: String = instance match {
override def cmd: Vector[String] = instance match {
case local: LndInstanceLocal =>
s"${binaryOpt.get} --lnddir=${local.datadir.toAbsolutePath}"
case _: LndInstanceRemote => ""
Vector(
binaryOpt.get.toString,
s"--lnddir=${local.datadir.toAbsolutePath}"
)
case _: LndInstanceRemote => Vector.empty
}
implicit val executionContext: ExecutionContext = system.dispatcher

View File

@ -59,7 +59,7 @@ class TorClient()(implicit
private lazy val executable = TorClient.torBinaryFromResource(conf.torDir)
/** The command to start the daemon on the underlying OS */
override lazy val cmd: String = {
override lazy val cmd: Vector[String] = {
val args = Vector(
"--ExitRelay 0", // ensure we aren't an exit relay
@ -71,9 +71,9 @@ class TorClient()(implicit
s"""--Log "notice file ${conf.torLogFile.toAbsolutePath}" """,
s"""--GeoIPFile "${conf.torDir.toAbsolutePath.resolve("geoip")}" """,
s"""--GeoIPv6File "${conf.torDir.toAbsolutePath.resolve("geoip6")}" """
).mkString(" ")
)
s"$executable $args"
executable.toString +: args
}
}