@Override
    protected void serviceInit(Configuration conf) throws Exception {
        Configuration config = new HboxConfiguration(conf);

        // config.setBoolean(Dispatcher.DISPATCHER_EXIT_ON_ERROR_KEY, true);

        // This is required for WebApps to use https if enabled.
        HboxWebAppUtil.initialize(getConfig());

        try {
            doSecureLogin(conf);
        } catch (IOException ie) {
            throw new YarnRuntimeException("History Server Failed to login", ie);
        }

        jobHistoryService = new JobHistory();
        historyContext = (HistoryContext) jobHistoryService;
        stateStore = createStateStore(conf);
        this.jhsDTSecretManager = createJHSSecretManager(conf, stateStore);
        clientService = createHistoryClientService(conf);

        addService(stateStore);
        addService(new HistoryServerSecretManagerService());
        addService(clientService);
        super.serviceInit(config);
    }
Priority of the JobHistoryServer shutdown hook.
history-server/src/main/java/net/qihoo/hbox/jobhistory/JobHistoryServer.java