|
@@ -35,6 +35,7 @@ import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
|
|
import org.apache.zookeeper.server.persistence.FileTxnSnapLog.DatadirException;
|
|
import org.apache.zookeeper.server.persistence.FileTxnSnapLog.DatadirException;
|
|
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException;
|
|
import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException;
|
|
import org.apache.zookeeper.server.util.JvmPauseMonitor;
|
|
import org.apache.zookeeper.server.util.JvmPauseMonitor;
|
|
|
|
+import org.apache.zookeeper.util.ServiceUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
@@ -69,29 +70,29 @@ public class ZooKeeperServerMain {
|
|
LOG.info(USAGE);
|
|
LOG.info(USAGE);
|
|
System.err.println(USAGE);
|
|
System.err.println(USAGE);
|
|
ZKAuditProvider.addServerStartFailureAuditLog();
|
|
ZKAuditProvider.addServerStartFailureAuditLog();
|
|
- System.exit(ExitCode.INVALID_INVOCATION.getValue());
|
|
|
|
|
|
+ ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue());
|
|
} catch (ConfigException e) {
|
|
} catch (ConfigException e) {
|
|
LOG.error("Invalid config, exiting abnormally", e);
|
|
LOG.error("Invalid config, exiting abnormally", e);
|
|
System.err.println("Invalid config, exiting abnormally");
|
|
System.err.println("Invalid config, exiting abnormally");
|
|
ZKAuditProvider.addServerStartFailureAuditLog();
|
|
ZKAuditProvider.addServerStartFailureAuditLog();
|
|
- System.exit(ExitCode.INVALID_INVOCATION.getValue());
|
|
|
|
|
|
+ ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue());
|
|
} catch (DatadirException e) {
|
|
} catch (DatadirException e) {
|
|
LOG.error("Unable to access datadir, exiting abnormally", e);
|
|
LOG.error("Unable to access datadir, exiting abnormally", e);
|
|
System.err.println("Unable to access datadir, exiting abnormally");
|
|
System.err.println("Unable to access datadir, exiting abnormally");
|
|
ZKAuditProvider.addServerStartFailureAuditLog();
|
|
ZKAuditProvider.addServerStartFailureAuditLog();
|
|
- System.exit(ExitCode.UNABLE_TO_ACCESS_DATADIR.getValue());
|
|
|
|
|
|
+ ServiceUtils.requestSystemExit(ExitCode.UNABLE_TO_ACCESS_DATADIR.getValue());
|
|
} catch (AdminServerException e) {
|
|
} catch (AdminServerException e) {
|
|
LOG.error("Unable to start AdminServer, exiting abnormally", e);
|
|
LOG.error("Unable to start AdminServer, exiting abnormally", e);
|
|
System.err.println("Unable to start AdminServer, exiting abnormally");
|
|
System.err.println("Unable to start AdminServer, exiting abnormally");
|
|
ZKAuditProvider.addServerStartFailureAuditLog();
|
|
ZKAuditProvider.addServerStartFailureAuditLog();
|
|
- System.exit(ExitCode.ERROR_STARTING_ADMIN_SERVER.getValue());
|
|
|
|
|
|
+ ServiceUtils.requestSystemExit(ExitCode.ERROR_STARTING_ADMIN_SERVER.getValue());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
LOG.error("Unexpected exception, exiting abnormally", e);
|
|
LOG.error("Unexpected exception, exiting abnormally", e);
|
|
ZKAuditProvider.addServerStartFailureAuditLog();
|
|
ZKAuditProvider.addServerStartFailureAuditLog();
|
|
- System.exit(ExitCode.UNEXPECTED_ERROR.getValue());
|
|
|
|
|
|
+ ServiceUtils.requestSystemExit(ExitCode.UNEXPECTED_ERROR.getValue());
|
|
}
|
|
}
|
|
LOG.info("Exiting normally");
|
|
LOG.info("Exiting normally");
|
|
- System.exit(ExitCode.EXECUTION_FINISHED.getValue());
|
|
|
|
|
|
+ ServiceUtils.requestSystemExit(ExitCode.EXECUTION_FINISHED.getValue());
|
|
}
|
|
}
|
|
|
|
|
|
protected void initializeAndRun(String[] args) throws ConfigException, IOException, AdminServerException {
|
|
protected void initializeAndRun(String[] args) throws ConfigException, IOException, AdminServerException {
|