mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Fix beacon server start up on Linux again
This commit is contained in:
parent
afd5dd4553
commit
a2cdcb149a
2 changed files with 25 additions and 11 deletions
|
@ -10,7 +10,6 @@ import lombok.experimental.UtilityClass;
|
|||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Contains basic functionality to start, communicate, and stop a remote beacon server.
|
||||
|
@ -43,10 +42,12 @@ public class BeaconServer {
|
|||
}
|
||||
|
||||
public static Process start(String installationBase) throws Exception {
|
||||
var daemonExecutable = getDaemonExecutable(installationBase);
|
||||
var daemonExecutable = getDaemonDebugExecutable(installationBase);
|
||||
// Tell daemon that we launched from an external tool
|
||||
var command = "\"" + daemonExecutable + "\" --external "
|
||||
+ (BeaconConfig.getDaemonArguments() != null ? BeaconConfig.getDaemonArguments() : "");
|
||||
var command = BeaconConfig.launchDaemonInDebugMode()
|
||||
? XPipeInstallation.createExternalAsyncLaunchCommand(
|
||||
installationBase, BeaconConfig.getDaemonArguments())
|
||||
: XPipeInstallation.createExternalLaunchCommand(getDaemonDebugExecutable(installationBase), BeaconConfig.getDaemonArguments());
|
||||
Process process =
|
||||
Runtime.getRuntime().exec(ShellTypes.getPlatformDefault().executeCommandWithShell(command));
|
||||
printDaemonOutput(process, command);
|
||||
|
@ -106,19 +107,18 @@ public class BeaconServer {
|
|||
return res.isSuccess();
|
||||
}
|
||||
|
||||
public static Path getDaemonExecutable(String installationBase) throws Exception {
|
||||
public static String getDaemonDebugExecutable(String installationBase) throws Exception {
|
||||
try (ShellProcessControl pc = new LocalStore().create().start()) {
|
||||
var debug = BeaconConfig.launchDaemonInDebugMode();
|
||||
if (!debug) {
|
||||
return Path.of(
|
||||
FileNames.join(installationBase, XPipeInstallation.getDaemonExecutablePath(pc.getOsType())));
|
||||
throw new IllegalStateException();
|
||||
} else {
|
||||
if (BeaconConfig.attachDebuggerToDaemon()) {
|
||||
return Path.of(FileNames.join(
|
||||
installationBase, XPipeInstallation.getDaemonDebugAttachScriptPath(pc.getOsType())));
|
||||
return FileNames.join(
|
||||
installationBase, XPipeInstallation.getDaemonDebugAttachScriptPath(pc.getOsType()));
|
||||
} else {
|
||||
return Path.of(FileNames.join(
|
||||
installationBase, XPipeInstallation.getDaemonDebugScriptPath(pc.getOsType())));
|
||||
return FileNames.join(
|
||||
installationBase, XPipeInstallation.getDaemonDebugScriptPath(pc.getOsType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,20 @@ import java.util.List;
|
|||
|
||||
public class XPipeInstallation {
|
||||
|
||||
public static String createExternalAsyncLaunchCommand(String installationBase, String arguments) {
|
||||
var suffix = (arguments != null ? arguments : "");
|
||||
if (OsType.getLocal().equals(OsType.LINUX)) {
|
||||
return "nohup \"" + installationBase + "/app/bin/xpiped\" --external & disown" + suffix;
|
||||
}
|
||||
|
||||
return FileNames.join(installationBase, XPipeInstallation.getDaemonExecutablePath(OsType.getLocal())) + suffix;
|
||||
}
|
||||
|
||||
public static String createExternalLaunchCommand(String command, String arguments) {
|
||||
var suffix = (arguments != null ? arguments : "");
|
||||
return "\"" + command + "\" --external" + suffix;
|
||||
}
|
||||
|
||||
public static String getInstallationBasePathForCLI(ShellProcessControl p, String cliExecutable) throws Exception {
|
||||
var defaultInstallation = getDefaultInstallationBasePath(p, true);
|
||||
if (cliExecutable == null) {
|
||||
|
|
Loading…
Reference in a new issue