forked from SteamWar/SteamWar
Add Debugger for remote JVM
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="Remote JVM Debugger" type="Remote">
|
||||||
|
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||||
|
<option name="SERVER_MODE" value="false" />
|
||||||
|
<option name="SHMEM_ADDRESS" />
|
||||||
|
<option name="HOST" value="localhost" />
|
||||||
|
<option name="PORT" value="5005" />
|
||||||
|
<option name="AUTO_RESTART" value="false" />
|
||||||
|
<RunnerSettings RunnerId="Debug">
|
||||||
|
<option name="DEBUG_PORT" value="5005" />
|
||||||
|
<option name="LOCAL" value="false" />
|
||||||
|
</RunnerSettings>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
@@ -86,6 +86,7 @@ class DevServer extends DefaultTask {
|
|||||||
|
|
||||||
if (worldName == null) worldName = properties.get("worldName")
|
if (worldName == null) worldName = properties.get("worldName")
|
||||||
host = properties.get("host")
|
host = properties.get("host")
|
||||||
|
debugPort = new Random().nextInt(5001, 10000)
|
||||||
|
|
||||||
if (host == null) {
|
if (host == null) {
|
||||||
throw new GradleException("Please supply the 'host' in a 'steamwar.properties' files either in this project dir or any parent project!")
|
throw new GradleException("Please supply the 'host' in a 'steamwar.properties' files either in this project dir or any parent project!")
|
||||||
@@ -94,6 +95,7 @@ class DevServer extends DefaultTask {
|
|||||||
doLast {
|
doLast {
|
||||||
setupTemplate(template)
|
setupTemplate(template)
|
||||||
uploadDependencies()
|
uploadDependencies()
|
||||||
|
startDebugPort()
|
||||||
startDevServer()
|
startDevServer()
|
||||||
}
|
}
|
||||||
finalizedBy(new Finalizer())
|
finalizedBy(new Finalizer())
|
||||||
@@ -105,6 +107,9 @@ class DevServer extends DefaultTask {
|
|||||||
@Internal
|
@Internal
|
||||||
String host
|
String host
|
||||||
|
|
||||||
|
@Internal
|
||||||
|
int debugPort
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
Boolean running = true
|
Boolean running = true
|
||||||
|
|
||||||
@@ -213,6 +218,17 @@ class DevServer extends DefaultTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void startDebugPort() {
|
||||||
|
def process = new ProcessBuilder("ssh", host, "-L", "5005:localhost:$debugPort").start()
|
||||||
|
def processOutput = new BufferedReader(new InputStreamReader(process.inputStream))
|
||||||
|
new Thread({
|
||||||
|
while (running) {
|
||||||
|
}
|
||||||
|
processOutput.close()
|
||||||
|
process.errorStream.close()
|
||||||
|
}).start()
|
||||||
|
}
|
||||||
|
|
||||||
void startDevServer() {
|
void startDevServer() {
|
||||||
def devPy = new StringBuilder().append("dev.py")
|
def devPy = new StringBuilder().append("dev.py")
|
||||||
if (port != null) devPy.append(" --port $port")
|
if (port != null) devPy.append(" --port $port")
|
||||||
@@ -225,6 +241,7 @@ class DevServer extends DefaultTask {
|
|||||||
devPy.append(" -D${dParam.key}=${dParam.value}")
|
devPy.append(" -D${dParam.key}=${dParam.value}")
|
||||||
}
|
}
|
||||||
devPy.append(" $template")
|
devPy.append(" $template")
|
||||||
|
devPy.append(" -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:$debugPort")
|
||||||
if (jvmArgs != null) devPy.append(" $jvmArgs")
|
if (jvmArgs != null) devPy.append(" $jvmArgs")
|
||||||
println("Starting $template with command ${devPy.toString()}")
|
println("Starting $template with command ${devPy.toString()}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user