Commit 1cabbeef authored by zeroleak's avatar zeroleak
Browse files

exit CLI on Tor start failure

parent 00a3931e
......@@ -3,6 +3,7 @@ package com.samourai.tor.client;
import com.msopentech.thali.java.toronionproxy.JavaOnionProxyContext;
import com.msopentech.thali.toronionproxy.*;
import com.samourai.tor.client.utils.WhirlpoolTorInstaller;
import com.samourai.whirlpool.cli.Application;
import com.samourai.whirlpool.cli.beans.CliProxy;
import com.samourai.whirlpool.cli.beans.CliProxyProtocol;
import com.samourai.whirlpool.client.exception.NotifiableException;
......@@ -61,8 +62,8 @@ public class TorOnionProxyInstance implements JavaTorConnexion {
throw new RuntimeException("Couldn't start tor");
}
} catch (Exception e) {
log.error("", e);
stop();
log.error("Tor failed to start", e);
Application.exitError(1);
}
},
"start-TorOnionProxyInstance");
......
......@@ -68,11 +68,7 @@ public class Application implements ApplicationRunner {
// exit
if (exitCode != null) {
// error
if (log.isDebugEnabled()) {
log.debug("Exit with error: " + exitCode);
}
SpringApplication.exit(applicationContext, () -> exitCode);
System.exit(exitCode);
exitError(exitCode);
} else {
// success
if (log.isDebugEnabled()) {
......@@ -163,6 +159,16 @@ public class Application implements ApplicationRunner {
thread.start();
}
public static void exitError(int exitCode) {
if (log.isDebugEnabled()) {
log.debug("Exit with error: " + exitCode);
}
if (applicationContext != null) {
SpringApplication.exit(applicationContext, () -> exitCode);
}
System.exit(exitCode);
}
private static String[] computeRestartArgs() {
return Arrays.stream(applicationArguments.getSourceArgs())
.filter(a -> !a.toLowerCase().equals("--" + ApplicationArgs.ARG_INIT))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment