macOS start/restart fixes

This commit is contained in:
crschnick 2024-05-26 20:43:55 +00:00
parent ec5342e50f
commit d62047d56b
4 changed files with 16 additions and 5 deletions

View file

@ -190,8 +190,9 @@ public abstract class OperationMode {
public static void restart() {
OperationMode.executeAfterShutdown(() -> {
var exec = XPipeInstallation.createExternalAsyncLaunchCommand(
XPipeInstallation.getCurrentInstallationBasePath().toString(), XPipeDaemonMode.GUI, "");
var loc = AppProperties.get().isDevelopmentEnvironment() ?
XPipeInstallation.getLocalDefaultInstallationBasePath() : XPipeInstallation.getCurrentInstallationBasePath().toString();
var exec = XPipeInstallation.createExternalAsyncLaunchCommand(loc, XPipeDaemonMode.GUI, "", true);
LocalShell.getShell().executeSimpleCommand(exec);
});
}
@ -233,6 +234,7 @@ public abstract class OperationMode {
}
public static void halt(int code) {
TrackEvent.info("Halting now!");
AppLogs.teardown();
Runtime.getRuntime().halt(code);
}
@ -288,6 +290,10 @@ public abstract class OperationMode {
// }
private static synchronized void set(OperationMode newMode) {
if (inShutdown) {
return;
}
if (CURRENT == null && newMode == null) {
return;
}

View file

@ -55,6 +55,7 @@ public class DesktopShortcuts {
exec, target);
try (var pc = LocalShell.getShell()) {
pc.getShellDialect().deleteFileOrDirectory(pc, base.toString()).executeAndCheck();
pc.executeSimpleCommand(pc.getShellDialect().getMkdirsCommand(base + "/Contents/MacOS"));
pc.executeSimpleCommand(pc.getShellDialect().getMkdirsCommand(base + "/Contents/Resources"));

View file

@ -48,7 +48,7 @@ public class BeaconServer {
String command;
if (!BeaconConfig.launchDaemonInDebugMode()) {
command = XPipeInstallation.createExternalAsyncLaunchCommand(
installationBase, mode, BeaconConfig.getDaemonArguments());
installationBase, mode, BeaconConfig.getDaemonArguments(), false);
} else {
command = XPipeInstallation.createExternalLaunchCommand(
getDaemonDebugExecutable(installationBase), BeaconConfig.getDaemonArguments(), mode);

View file

@ -35,14 +35,18 @@ public class XPipeInstallation {
}
public static String createExternalAsyncLaunchCommand(
String installationBase, XPipeDaemonMode mode, String arguments) {
String installationBase, XPipeDaemonMode mode, String arguments, boolean restart) {
var suffix = (arguments != null ? " " + arguments : "");
var modeOption = mode != null ? " --mode " + mode.getDisplayName() : "";
if (OsType.getLocal().equals(OsType.LINUX)) {
return "nohup \"" + installationBase + "/app/bin/xpiped\"" + modeOption + suffix + " & disown";
} else if (OsType.getLocal().equals(OsType.MACOS)) {
if (restart) {
return "(sleep 1;open \"" + installationBase + "\" --args" + modeOption + suffix + "</dev/null &>/dev/null) & disown";
} else {
return "open \"" + installationBase + "\" --args" + modeOption + suffix;
}
}
return "\"" + FileNames.join(installationBase, XPipeInstallation.getDaemonExecutablePath(OsType.getLocal()))
+ "\"" + modeOption + suffix;