|
35 | 35 | import org.apache.zookeeper.server.persistence.FileTxnSnapLog.DatadirException;
|
36 | 36 | import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException;
|
37 | 37 | import org.apache.zookeeper.server.util.JvmPauseMonitor;
|
| 38 | +import org.apache.zookeeper.util.ServiceUtils; |
38 | 39 | import org.slf4j.Logger;
|
39 | 40 | import org.slf4j.LoggerFactory;
|
40 | 41 |
|
@@ -69,29 +70,29 @@ public static void main(String[] args) {
|
69 | 70 | LOG.info(USAGE);
|
70 | 71 | System.err.println(USAGE);
|
71 | 72 | ZKAuditProvider.addServerStartFailureAuditLog();
|
72 |
| - System.exit(ExitCode.INVALID_INVOCATION.getValue()); |
| 73 | + ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue()); |
73 | 74 | } catch (ConfigException e) {
|
74 | 75 | LOG.error("Invalid config, exiting abnormally", e);
|
75 | 76 | System.err.println("Invalid config, exiting abnormally");
|
76 | 77 | ZKAuditProvider.addServerStartFailureAuditLog();
|
77 |
| - System.exit(ExitCode.INVALID_INVOCATION.getValue()); |
| 78 | + ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue()); |
78 | 79 | } catch (DatadirException e) {
|
79 | 80 | LOG.error("Unable to access datadir, exiting abnormally", e);
|
80 | 81 | System.err.println("Unable to access datadir, exiting abnormally");
|
81 | 82 | ZKAuditProvider.addServerStartFailureAuditLog();
|
82 |
| - System.exit(ExitCode.UNABLE_TO_ACCESS_DATADIR.getValue()); |
| 83 | + ServiceUtils.requestSystemExit(ExitCode.UNABLE_TO_ACCESS_DATADIR.getValue()); |
83 | 84 | } catch (AdminServerException e) {
|
84 | 85 | LOG.error("Unable to start AdminServer, exiting abnormally", e);
|
85 | 86 | System.err.println("Unable to start AdminServer, exiting abnormally");
|
86 | 87 | ZKAuditProvider.addServerStartFailureAuditLog();
|
87 |
| - System.exit(ExitCode.ERROR_STARTING_ADMIN_SERVER.getValue()); |
| 88 | + ServiceUtils.requestSystemExit(ExitCode.ERROR_STARTING_ADMIN_SERVER.getValue()); |
88 | 89 | } catch (Exception e) {
|
89 | 90 | LOG.error("Unexpected exception, exiting abnormally", e);
|
90 | 91 | ZKAuditProvider.addServerStartFailureAuditLog();
|
91 |
| - System.exit(ExitCode.UNEXPECTED_ERROR.getValue()); |
| 92 | + ServiceUtils.requestSystemExit(ExitCode.UNEXPECTED_ERROR.getValue()); |
92 | 93 | }
|
93 | 94 | LOG.info("Exiting normally");
|
94 |
| - System.exit(ExitCode.EXECUTION_FINISHED.getValue()); |
| 95 | + ServiceUtils.requestSystemExit(ExitCode.EXECUTION_FINISHED.getValue()); |
95 | 96 | }
|
96 | 97 |
|
97 | 98 | protected void initializeAndRun(String[] args) throws ConfigException, IOException, AdminServerException {
|
|
0 commit comments