-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63ef6e1
commit acbc3da
Showing
16 changed files
with
172 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/com/kotlang/remoting/LocalTargetManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.kotlang.remoting | ||
|
||
import com.kotlang.hostManagerPath | ||
import com.kotlang.util.PortUtil | ||
|
||
class LocalTargetManager: RemoteTargetManager() { | ||
private val availablePort = PortUtil.getFreePort() | ||
override fun runRemoteHostManager(): Process { | ||
val os = System.getProperty("os.name").toLowerCase() | ||
val hostAgentUrl = getHostAgentUrl(os) | ||
|
||
if (os.indexOf("mac") >= 0 || os.indexOf("linux") >= 0) { | ||
val p = Runtime.getRuntime().exec("chmod +x $hostAgentUrl") | ||
p.waitFor() | ||
} | ||
|
||
return Runtime.getRuntime().exec("$hostAgentUrl :$availablePort $hostManagerPath/hostManager/app.log") | ||
} | ||
|
||
override val port: Int | ||
get() = availablePort | ||
override val host: String | ||
get() = "localhost" | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/com/kotlang/remoting/RemoteTargetManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.kotlang.remoting | ||
|
||
import com.kotlang.hostManagerPath | ||
|
||
abstract class RemoteTargetManager { | ||
abstract fun runRemoteHostManager(): Process | ||
|
||
abstract val port: Int | ||
abstract val host: String | ||
|
||
fun getHostAgentUrl(os: String): String { | ||
return when { | ||
os.indexOf("win") >= 0 -> "$hostManagerPath/hostManager/windows/OmnishellProcessManager.exe" | ||
os.indexOf("mac") >= 0 -> { | ||
val hostAgentUrl = "$hostManagerPath/hostManager/mac/OmnishellProcessManager" | ||
hostAgentUrl | ||
} | ||
else -> { | ||
val hostAgentUrl = "$hostManagerPath/hostManager/linux/OmnishellProcessManager" | ||
hostAgentUrl | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.kotlang.remoting | ||
|
||
import com.kotlang.hostManagerPath | ||
import com.kotlang.util.PortUtil | ||
import java.util.* | ||
|
||
class WslTargetManager(private val wslTarget: String): RemoteTargetManager() { | ||
companion object { | ||
fun listWsl(): List<String> { | ||
val os = System.getProperty("os.name").toLowerCase() | ||
val result = mutableListOf<String>() | ||
if (os.indexOf("win") >= 0) { | ||
val process = Runtime.getRuntime().exec("wsl --list") | ||
process.waitFor() | ||
val sc = Scanner(process.inputStream) | ||
sc.nextLine() | ||
while (sc.hasNextLine()) { | ||
var outLine = sc.nextLine() | ||
|
||
outLine = outLine.replace(0.toChar().toString(), "") | ||
outLine = outLine.removeSuffix("(Default)").trim() | ||
if (outLine.isNotEmpty()) { | ||
result.add(outLine) | ||
} | ||
} | ||
} | ||
return result | ||
} | ||
} | ||
|
||
fun getWslPath(windowsPath: String): String { | ||
var process = Runtime.getRuntime().exec("wsl wslpath $windowsPath") | ||
process.waitFor() | ||
val sc = Scanner(process.inputStream) | ||
//get wsl path from command output | ||
val wslPath = sc.nextLine().replace(0.toChar().toString(), "") | ||
|
||
//make the file executable | ||
process = Runtime.getRuntime().exec("$wslTarget run chmod +x $wslPath") | ||
process.waitFor() | ||
return wslPath | ||
} | ||
|
||
private val availablePort = PortUtil.getFreePort() | ||
override fun runRemoteHostManager(): Process { | ||
val hostAgentUrl = getWslPath(getHostAgentUrl("linux").replace("\\", "/")) | ||
val hostManagerPathWsl = getWslPath(hostManagerPath.toString().replace("\\", "/")) | ||
|
||
return Runtime.getRuntime().exec("$wslTarget run $hostAgentUrl :$availablePort $hostManagerPathWsl/hostManager/appWsl.log") | ||
} | ||
|
||
override val port: Int | ||
get() = availablePort | ||
override val host: String | ||
get() = "localhost" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.