Introduce API for daemon modes

This commit is contained in:
Christopher Schnick
2023-01-09 06:19:02 +01:00
parent 73f3521ee8
commit c882057067
9 changed files with 69 additions and 12 deletions
@@ -1,5 +1,6 @@
package io.xpipe.beacon;
import io.xpipe.core.util.XPipeDaemonMode;
import io.xpipe.core.util.XPipeInstallation;
import java.io.IOException;
@@ -8,7 +9,7 @@ public class BeaconDaemonController {
private static boolean alreadyStarted;
public static void start() throws Exception {
public static void start(XPipeDaemonMode mode) throws Exception {
if (BeaconServer.isRunning()) {
alreadyStarted = true;
return;
@@ -20,7 +21,7 @@ public class BeaconDaemonController {
custom = true;
} else {
var defaultBase = XPipeInstallation.getLocalDefaultInstallationBasePath(true);
process = BeaconServer.start(defaultBase);
process = BeaconServer.start(defaultBase, mode);
}
waitForStartup(process, custom);
@@ -4,6 +4,7 @@ import io.xpipe.beacon.exchange.StopExchange;
import io.xpipe.core.impl.FileNames;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellTypes;
import io.xpipe.core.util.XPipeDaemonMode;
import io.xpipe.core.util.XPipeInstallation;
import java.io.BufferedReader;
@@ -39,10 +40,10 @@ public class BeaconServer {
return null;
}
public static Process start(String installationBase) throws Exception {
public static Process start(String installationBase, XPipeDaemonMode mode) throws Exception {
String command;
if (!BeaconConfig.launchDaemonInDebugMode()) {
command = XPipeInstallation.createExternalAsyncLaunchCommand(installationBase, BeaconConfig.getDaemonArguments());
command = XPipeInstallation.createExternalAsyncLaunchCommand(installationBase, mode, BeaconConfig.getDaemonArguments());
} else {
command = XPipeInstallation.createExternalLaunchCommand(
getDaemonDebugExecutable(installationBase), BeaconConfig.getDaemonArguments());
@@ -2,7 +2,9 @@ package io.xpipe.beacon.exchange;
import io.xpipe.beacon.RequestMessage;
import io.xpipe.beacon.ResponseMessage;
import io.xpipe.core.util.XPipeDaemonMode;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
import lombok.extern.jackson.Jacksonized;
@@ -17,6 +19,8 @@ public class FocusExchange implements MessageExchange {
@Builder
@Value
public static class Request implements RequestMessage {
@NonNull
XPipeDaemonMode mode;
}
@Jacksonized
@@ -3,6 +3,7 @@ package io.xpipe.beacon.exchange.cli;
import io.xpipe.beacon.RequestMessage;
import io.xpipe.beacon.ResponseMessage;
import io.xpipe.beacon.exchange.MessageExchange;
import io.xpipe.core.util.XPipeDaemonMode;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
@@ -20,12 +21,14 @@ public class ModeExchange implements MessageExchange {
@Value
public static class Request implements RequestMessage {
@NonNull
String modeId;
XPipeDaemonMode mode;
}
@Jacksonized
@Builder
@Value
public static class Response implements ResponseMessage {
@NonNull
XPipeDaemonMode usedMode;
}
}