This commit is contained in:
@@ -7,6 +7,7 @@ import de.steamwar.commands.database.DatabaseCommand
|
|||||||
import de.steamwar.commands.database.InfoCommand
|
import de.steamwar.commands.database.InfoCommand
|
||||||
import de.steamwar.commands.database.ResetCommand
|
import de.steamwar.commands.database.ResetCommand
|
||||||
import de.steamwar.commands.dev.DevCommand
|
import de.steamwar.commands.dev.DevCommand
|
||||||
|
import de.steamwar.commands.profiler.ProfilerCommand
|
||||||
import de.steamwar.commands.user.UserCommand
|
import de.steamwar.commands.user.UserCommand
|
||||||
import de.steamwar.commands.user.UserInfoCommand
|
import de.steamwar.commands.user.UserInfoCommand
|
||||||
import de.steamwar.commands.user.UserSearchCommand
|
import de.steamwar.commands.user.UserSearchCommand
|
||||||
@@ -15,6 +16,7 @@ fun main(args: Array<String>) = SteamWar()
|
|||||||
.subcommands(
|
.subcommands(
|
||||||
DatabaseCommand().subcommands(InfoCommand(), ResetCommand()),
|
DatabaseCommand().subcommands(InfoCommand(), ResetCommand()),
|
||||||
UserCommand().subcommands(UserInfoCommand(), UserSearchCommand()),
|
UserCommand().subcommands(UserInfoCommand(), UserSearchCommand()),
|
||||||
DevCommand()
|
DevCommand(),
|
||||||
|
ProfilerCommand()
|
||||||
)
|
)
|
||||||
.main(args)
|
.main(args)
|
||||||
38
src/main/kotlin/commands/profiler/ProfilerCommand.kt
Normal file
38
src/main/kotlin/commands/profiler/ProfilerCommand.kt
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package de.steamwar.commands.profiler
|
||||||
|
|
||||||
|
import com.github.ajalt.clikt.core.CliktCommand
|
||||||
|
import com.github.ajalt.clikt.core.Context
|
||||||
|
import com.github.ajalt.clikt.parameters.arguments.argument
|
||||||
|
import com.github.ajalt.clikt.parameters.arguments.help
|
||||||
|
import com.github.ajalt.clikt.parameters.arguments.optional
|
||||||
|
import com.github.ajalt.clikt.parameters.options.default
|
||||||
|
import com.github.ajalt.clikt.parameters.options.option
|
||||||
|
import com.github.ajalt.clikt.parameters.types.int
|
||||||
|
|
||||||
|
class ProfilerCommand: CliktCommand("profiler") {
|
||||||
|
val pid by argument().help("Process id").int().optional()
|
||||||
|
val port by option("--port", "-p").int().default(8543)
|
||||||
|
|
||||||
|
override fun run() {
|
||||||
|
if (pid != null) {
|
||||||
|
ProcessBuilder()
|
||||||
|
.command("java", "-jar", "/jars/spark.java", pid.toString(), "port=$port")
|
||||||
|
.start()
|
||||||
|
.waitFor()
|
||||||
|
|
||||||
|
ProcessBuilder()
|
||||||
|
.command("ssh", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-p", port.toString(), "spark@localhost")
|
||||||
|
.inheritIO()
|
||||||
|
.start()
|
||||||
|
.waitFor()
|
||||||
|
} else {
|
||||||
|
ProcessBuilder()
|
||||||
|
.command("java", "-jar", "/jars/spark.java")
|
||||||
|
.inheritIO()
|
||||||
|
.start()
|
||||||
|
.waitFor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun help(context: Context): String = "Start a profiler"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user