mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-02 02:31:21 +12:00
More fixes for beacon server start up
This commit is contained in:
parent
5266749c09
commit
d949f661ce
3 changed files with 26 additions and 6 deletions
|
@ -30,11 +30,13 @@ public class BeaconServer {
|
||||||
public static Process tryStartCustom() throws Exception {
|
public static Process tryStartCustom() throws Exception {
|
||||||
var custom = BeaconConfig.getCustomDaemonCommand();
|
var custom = BeaconConfig.getCustomDaemonCommand();
|
||||||
if (custom != null) {
|
if (custom != null) {
|
||||||
var command =
|
var command = ShellTypes.getPlatformDefault()
|
||||||
ShellTypes.getPlatformDefault().executeCommandWithShell(
|
.executeCommandListWithShell(custom
|
||||||
custom + (BeaconConfig.getDaemonArguments() != null ? " " + BeaconConfig.getDaemonArguments() : ""));
|
+ (BeaconConfig.getDaemonArguments() != null
|
||||||
Process process = Runtime.getRuntime().exec(command);
|
? " " + BeaconConfig.getDaemonArguments()
|
||||||
printDaemonOutput(process, command);
|
: ""));
|
||||||
|
Process process = Runtime.getRuntime().exec(command.toArray(String[]::new));
|
||||||
|
printDaemonOutput(process, ShellTypes.getPlatformDefault().flatten(command));
|
||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -45,7 +47,8 @@ public class BeaconServer {
|
||||||
// Tell daemon that we launched from an external tool
|
// Tell daemon that we launched from an external tool
|
||||||
var command = "\"" + daemonExecutable + "\" --external "
|
var command = "\"" + daemonExecutable + "\" --external "
|
||||||
+ (BeaconConfig.getDaemonArguments() != null ? BeaconConfig.getDaemonArguments() : "");
|
+ (BeaconConfig.getDaemonArguments() != null ? BeaconConfig.getDaemonArguments() : "");
|
||||||
Process process = Runtime.getRuntime().exec(ShellTypes.getPlatformDefault().executeCommandWithShell(command));
|
Process process =
|
||||||
|
Runtime.getRuntime().exec(ShellTypes.getPlatformDefault().executeCommandWithShell(command));
|
||||||
printDaemonOutput(process, command);
|
printDaemonOutput(process, command);
|
||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,8 @@ public interface ShellType {
|
||||||
|
|
||||||
String executeCommandWithShell(String cmd);
|
String executeCommandWithShell(String cmd);
|
||||||
|
|
||||||
|
List<String> executeCommandListWithShell(String cmd);
|
||||||
|
|
||||||
List<String> createMkdirsCommand(String dirs);
|
List<String> createMkdirsCommand(String dirs);
|
||||||
|
|
||||||
String createFileReadCommand(String file);
|
String createFileReadCommand(String file);
|
||||||
|
|
|
@ -140,6 +140,11 @@ public class ShellTypes {
|
||||||
return "cmd.exe /C " + cmd + "";
|
return "cmd.exe /C " + cmd + "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> executeCommandListWithShell(String cmd) {
|
||||||
|
return List.of("cmd", "/C", cmd);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> createMkdirsCommand(String dirs) {
|
public List<String> createMkdirsCommand(String dirs) {
|
||||||
return List.of("(", "if", "not", "exist", dirs, "mkdir", dirs, ")");
|
return List.of("(", "if", "not", "exist", dirs, "mkdir", dirs, ")");
|
||||||
|
@ -232,6 +237,11 @@ public class ShellTypes {
|
||||||
return "$env:" + variableName + " = \"" + escapeStringValue(value) + "\"";
|
return "$env:" + variableName + " = \"" + escapeStringValue(value) + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> executeCommandListWithShell(String cmd) {
|
||||||
|
return List.of("powershell", "-Command", cmd);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String queryShellProcessId(ShellProcessControl control) throws IOException {
|
public String queryShellProcessId(ShellProcessControl control) throws IOException {
|
||||||
control.writeLine("echo $PID");
|
control.writeLine("echo $PID");
|
||||||
|
@ -387,6 +397,11 @@ public class ShellTypes {
|
||||||
|
|
||||||
public abstract static class PosixBase implements ShellType {
|
public abstract static class PosixBase implements ShellType {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> executeCommandListWithShell(String cmd) {
|
||||||
|
return List.of(getExecutable(), "-c", cmd);
|
||||||
|
}
|
||||||
|
|
||||||
public String getScriptEchoCommand(String s) {
|
public String getScriptEchoCommand(String s) {
|
||||||
return "#!" + getExecutable() + "\n" + getEchoCommand(s, false) + "\nrm -- \"$0\"";
|
return "#!" + getExecutable() + "\n" + getEchoCommand(s, false) + "\nrm -- \"$0\"";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue