mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Merge pull request #6866 from alvasw/gradle_regtest_seednodes
Regtest: Implement seednode start tasks
This commit is contained in:
commit
45ba4c4f82
@ -6,12 +6,57 @@ import org.gradle.kotlin.dsl.register
|
||||
|
||||
class RegtestPlugin : Plugin<Project> {
|
||||
|
||||
companion object {
|
||||
const val RPC_USER = "bisqdao"
|
||||
const val RPC_PASSWORD = "bsq"
|
||||
}
|
||||
|
||||
override fun apply(project: Project) {
|
||||
val startBitcoindTask = project.tasks.register<StartBitcoindTask>("startBitcoindRegtest") {
|
||||
val startBitcoindTask = project.tasks.register<StartBitcoindTask>("startRegtestBitcoind") {
|
||||
dataDirectory.set(project.layout.projectDirectory.dir(".localnet/bitcoind"))
|
||||
rpcUser.set("bisqdao")
|
||||
rpcPassword.set("bsq")
|
||||
rpcUser.set(RPC_USER)
|
||||
rpcPassword.set(RPC_PASSWORD)
|
||||
blockNotifyArg.set(".localnet/bitcoind/blocknotify %s")
|
||||
}
|
||||
|
||||
val startFirstSeedNodeTask = project.tasks.register<StartSeedNodeTask>("startRegtestFirstSeednode") {
|
||||
dependsOn(startBitcoindTask)
|
||||
startScriptFile.set(project.layout.projectDirectory.file("bisq-seednode"))
|
||||
|
||||
arguments.set(
|
||||
createSeedNodeArgs(5120, 2002, "seednode")
|
||||
)
|
||||
|
||||
workingDirectory.set(project.layout.projectDirectory)
|
||||
logFile.set(project.layout.projectDirectory.file(".localnet/seednode_1_shell.log"))
|
||||
}
|
||||
|
||||
val startSecondSeedNodeTask = project.tasks.register<StartSeedNodeTask>("startRegtestSecondSeednode") {
|
||||
dependsOn(startBitcoindTask)
|
||||
dependsOn(startFirstSeedNodeTask)
|
||||
startScriptFile.set(project.layout.projectDirectory.file("bisq-seednode"))
|
||||
|
||||
arguments.set(
|
||||
createSeedNodeArgs(5121, 3002, "seednode2")
|
||||
)
|
||||
|
||||
workingDirectory.set(project.layout.projectDirectory)
|
||||
logFile.set(project.layout.projectDirectory.file(".localnet/seednode_2_shell.log"))
|
||||
}
|
||||
}
|
||||
|
||||
private fun createSeedNodeArgs(blockNotificationPort: Int, nodePort: Int, appName: String): List<String> = listOf(
|
||||
"--baseCurrencyNetwork=BTC_REGTEST",
|
||||
"--useLocalhostForP2P=true",
|
||||
"--useDevPrivilegeKeys=true",
|
||||
"--fullDaoNode=true",
|
||||
|
||||
"--rpcUser=${RPC_USER}",
|
||||
"--rpcPassword=${RPC_PASSWORD}",
|
||||
"--rpcBlockNotificationPort=$blockNotificationPort",
|
||||
|
||||
"--nodePort=$nodePort",
|
||||
"--userDataDir=.localnet",
|
||||
"--appName=$appName"
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package bisq.gradle.regtest_plugin
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.provider.ListProperty
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputDirectory
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
|
||||
abstract class StartSeedNodeTask : DefaultTask() {
|
||||
|
||||
@get:InputFile
|
||||
abstract val startScriptFile: RegularFileProperty
|
||||
|
||||
@get:Input
|
||||
abstract val arguments: ListProperty<String>
|
||||
|
||||
@get:InputDirectory
|
||||
abstract val workingDirectory: DirectoryProperty
|
||||
|
||||
@get:Internal
|
||||
abstract val logFile: RegularFileProperty
|
||||
|
||||
@TaskAction
|
||||
fun run() {
|
||||
val processBuilder = ProcessBuilder(
|
||||
"bash", startScriptFile.asFile.get().absolutePath, arguments.get().joinToString(" ")
|
||||
)
|
||||
|
||||
processBuilder.directory(workingDirectory.asFile.get())
|
||||
processBuilder.redirectErrorStream(true)
|
||||
processBuilder.redirectOutput(logFile.asFile.get())
|
||||
|
||||
processBuilder.start()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user