private static void notifyStopped() { DaemonStarter.currentPhase.set(LifecyclePhase.STOPPED); DaemonStarter.rlog.info("{} stopped!", DaemonStarter.daemonName); DaemonStarter.getLifecycleListener().stopped(); }
private static void notifyStarted() { DaemonStarter.currentPhase.set(LifecyclePhase.STARTED); DaemonStarter.rlog.info("{} started!", DaemonStarter.daemonName); DaemonStarter.getLifecycleListener().started(); }
private static void notifyStopped() { DaemonStarter.currentPhase.set(LifecyclePhase.STOPPED); DaemonStarter.rlog.info(DaemonStarter.daemonName + " stopped!"); DaemonStarter.getLifecycleListener().stopped(); }
private static void notifyStarted() { DaemonStarter.currentPhase.set(LifecyclePhase.STARTED); DaemonStarter.rlog.info(DaemonStarter.daemonName + " started!"); DaemonStarter.getLifecycleListener().started(); }
/** * Abort the daemon * * @param error the error causing the abortion */ public static void abortSystem(final Throwable error) { DaemonStarter.currentPhase.set(LifecyclePhase.ABORTING); try { DaemonStarter.getLifecycleListener().aborting(); } catch (Exception e) { DaemonStarter.rlog.error("Custom abort failed", e); } if (error != null) { DaemonStarter.rlog.error("Unrecoverable error encountered --> Exiting : " + error.getMessage()); DaemonStarter.getLifecycleListener().exception(LifecyclePhase.ABORTING, error); } else { DaemonStarter.rlog.error("Unrecoverable error encountered --> Exiting"); } // Exit system with failure return code System.exit(1); } }
/** * Abort the daemon * * @param error the error causing the abortion */ public static void abortSystem(final Throwable error) { DaemonStarter.currentPhase.set(LifecyclePhase.ABORTING); try { DaemonStarter.getLifecycleListener().aborting(); } catch (Exception e) { DaemonStarter.rlog.error("Custom abort failed", e); } if (error != null) { DaemonStarter.rlog.error("Unrecoverable error encountered --> Exiting : {}", error.getMessage()); DaemonStarter.getLifecycleListener().exception(LifecyclePhase.ABORTING, error); } else { DaemonStarter.rlog.error("Unrecoverable error encountered --> Exiting"); } // Exit system with failure return code System.exit(1); }
@SuppressWarnings("unchecked") private static void configureLogging() { String clazz = System.getProperty(DaemonProperties.LOGGER_CONFIGURER); if (clazz != null) { try { Class<ILoggingConfigurer> configurerClazz = (Class<ILoggingConfigurer>) Class.forName(clazz); DaemonStarter.loggingConfigurer.set(configurerClazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { DaemonStarter.rlog.warn("No ILoggingConfigurer set"); } } try { if (DaemonStarter.loggingConfigurer.get() != null) { DaemonStarter.loggingConfigurer.get().initializeLogging(); } } catch (final Exception e) { System.err.println("Logger config failed with exception: " + e.getMessage()); DaemonStarter.getLifecycleListener().exception(DaemonStarter.currentPhase.get(), e); } }
@SuppressWarnings("unchecked") private static void configureLogging() { String clazz = System.getProperty(DaemonProperties.LOGGER_CONFIGURER); if (clazz != null) { try { Class<ILoggingConfigurer> configurerClazz = (Class<ILoggingConfigurer>) Class.forName(clazz); DaemonStarter.loggingConfigurer.set(configurerClazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { DaemonStarter.rlog.warn("No ILoggingConfigurer set"); } } try { if (DaemonStarter.loggingConfigurer.get() != null) { DaemonStarter.loggingConfigurer.get().initializeLogging(); } } catch (final Exception e) { System.err.println("Logger config failed with exception: " + e.getMessage()); DaemonStarter.getLifecycleListener().exception(DaemonStarter.currentPhase.get(), e); } }
private static void initProperties() { try { // Loading properties final Map<String, String> properties = DaemonStarter.getLifecycleListener().loadProperties(); if (properties != null) { for (final Entry<String, String> e : properties.entrySet()) { DaemonStarter.addProperty(e.getKey(), String.valueOf(e.getValue())); } } } catch (final Exception e) { DaemonStarter.rlog.error("Getting config data failed", e); DaemonStarter.abortSystem(e); } }
private static void initProperties() { try { // Loading properties final Map<String, String> properties = DaemonStarter.getLifecycleListener().loadProperties(); if (properties != null) { for (final Entry<String, String> e : properties.entrySet()) { DaemonStarter.addProperty(e.getKey(), String.valueOf(e.getValue())); } } } catch (final Exception e) { DaemonStarter.rlog.error("Getting config data failed", e); DaemonStarter.abortSystem(e); } }
/** * Stop the service and end the program */ public static void stopService() { DaemonStarter.currentPhase.set(LifecyclePhase.STOPPING); final CountDownLatch cdl = new CountDownLatch(1); Executors.newSingleThreadExecutor().execute(() -> { DaemonStarter.getLifecycleListener().stopping(); DaemonStarter.daemon.stop(); cdl.countDown(); }); try { int timeout = DaemonStarter.lifecycleListener.get().getShutdownTimeoutSeconds(); if (!cdl.await(timeout, TimeUnit.SECONDS)) { DaemonStarter.rlog.error("Failed to stop gracefully"); DaemonStarter.abortSystem(); } } catch (InterruptedException e) { DaemonStarter.rlog.error("Failure awaiting stop", e); Thread.currentThread().interrupt(); } }
DaemonStarter.getLifecycleListener().exception(DaemonStarter.currentPhase.get(), e); DaemonStarter.getLifecycleListener().doStart(); } catch (Exception e) { DaemonStarter.abortSystem(e); DaemonStarter.getLifecycleListener().doStop(); } catch (Exception e) { DaemonStarter.abortSystem(e);
DaemonStarter.getLifecycleListener().exception(DaemonStarter.currentPhase.get(), e); DaemonStarter.getLifecycleListener().doStart(); } catch (Exception e) { DaemonStarter.abortSystem(e); DaemonStarter.getLifecycleListener().doStop(); } catch (Exception e) { DaemonStarter.abortSystem(e);
DaemonStarter.getLifecycleListener().signalUSR2(); }); } catch (IllegalArgumentException e) {