mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Rework launcher error handling
This commit is contained in:
parent
e26240ac1f
commit
f6a112510c
1 changed files with 37 additions and 37 deletions
|
@ -81,11 +81,11 @@ public class LauncherCommand implements Callable<Integer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkStart() {
|
private void checkStart() {
|
||||||
try {
|
var port = AppBeaconServer.get().getPort();
|
||||||
var port = AppBeaconServer.get().getPort();
|
var client = BeaconClient.tryEstablishConnection(
|
||||||
var client = BeaconClient.tryEstablishConnection(
|
port, BeaconClientInformation.Daemon.builder().build());
|
||||||
port, BeaconClientInformation.Daemon.builder().build());
|
if (client.isPresent()) {
|
||||||
if (client.isPresent()) {
|
try {
|
||||||
client.get()
|
client.get()
|
||||||
.performRequest(DaemonFocusExchange.Request.builder()
|
.performRequest(DaemonFocusExchange.Request.builder()
|
||||||
.mode(getEffectiveMode())
|
.mode(getEffectiveMode())
|
||||||
|
@ -96,41 +96,41 @@ public class LauncherCommand implements Callable<Integer> {
|
||||||
.arguments(inputs)
|
.arguments(inputs)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
if (OsType.getLocal().equals(OsType.MACOS)) {
|
var cli = XPipeInstallation.getLocalDefaultCliExecutable();
|
||||||
Desktop.getDesktop().setOpenURIHandler(e -> {
|
ErrorEvent.fromThrowable("Unable to connect to existing running daemon instance as it did not respond."
|
||||||
try {
|
+ " Either try to kill the process xpiped manually or use the command \"" + cli
|
||||||
client.get()
|
+ "\" daemon stop --force.", ex)
|
||||||
.performRequest(DaemonOpenExchange.Request.builder()
|
.term()
|
||||||
.arguments(List.of(e.getURI().toString()))
|
.expected()
|
||||||
.build());
|
.handle();
|
||||||
} catch (Exception ex) {
|
|
||||||
ErrorEvent.fromThrowable(ex).expected().omit().handle();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ThreadHelper.sleep(1000);
|
|
||||||
}
|
|
||||||
TrackEvent.info("Another instance is already running on this port. Quitting ...");
|
|
||||||
OperationMode.halt(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Even in case we are unable to reach another beacon server
|
if (OsType.getLocal().equals(OsType.MACOS)) {
|
||||||
// there might be another instance running, for example
|
Desktop.getDesktop().setOpenURIHandler(e -> {
|
||||||
// starting up or listening on another port
|
try {
|
||||||
if (!AppDataLock.lock()) {
|
client.get()
|
||||||
TrackEvent.info(
|
.performRequest(DaemonOpenExchange.Request.builder()
|
||||||
"Data directory " + AppProperties.get().getDataDir().toString()
|
.arguments(List.of(e.getURI().toString()))
|
||||||
+ " is already locked. Is another instance running?");
|
.build());
|
||||||
OperationMode.halt(1);
|
} catch (Exception ex) {
|
||||||
|
ErrorEvent.fromThrowable(ex).expected().omit().handle();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ThreadHelper.sleep(1000);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
TrackEvent.info("Another instance is already running on this port. Quitting ...");
|
||||||
var cli = XPipeInstallation.getLocalDefaultCliExecutable();
|
OperationMode.halt(1);
|
||||||
ErrorEvent.fromThrowable(ex)
|
}
|
||||||
.term()
|
|
||||||
.description("Unable to connect to existing running daemon instance as it did not respond."
|
// Even in case we are unable to reach another beacon server
|
||||||
+ " Either try to kill the process xpiped manually or use the command \"" + cli
|
// there might be another instance running, for example
|
||||||
+ "\" daemon stop --force.")
|
// starting up or listening on another port
|
||||||
.handle();
|
if (!AppDataLock.lock()) {
|
||||||
|
TrackEvent.info(
|
||||||
|
"Data directory " + AppProperties.get().getDataDir().toString()
|
||||||
|
+ " is already locked. Is another instance running?");
|
||||||
|
OperationMode.halt(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue