/** * Abort the daemon */ public static void abortSystem() { DaemonStarter.abortSystem(null); }
/** * Abort the daemon */ public static void abortSystem() { DaemonStarter.abortSystem(null); }
private static void determineHostname() { try { final String host = InetAddress.getLocalHost().getHostName(); if ((host != null) && !host.isEmpty()) { DaemonStarter.hostname.set(host); } else { DaemonStarter.rlog.error("Hostname could not be determined --> Exiting"); DaemonStarter.abortSystem(); } } catch (final UnknownHostException e) { DaemonStarter.rlog.error("Getting hostname failed", e); DaemonStarter.abortSystem(e); } }
private static void determineHostname() { try { final String host = InetAddress.getLocalHost().getHostName(); if ((host != null) && !host.isEmpty()) { DaemonStarter.hostname.set(host); } else { DaemonStarter.rlog.error("Hostname could not be determined --> Exiting"); DaemonStarter.abortSystem(); } } catch (final UnknownHostException e) { DaemonStarter.rlog.error("Getting hostname 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(new Runnable() { @Override public void run() { 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); } }
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().doStart(); } catch (Exception e) { DaemonStarter.abortSystem(e); DaemonStarter.getLifecycleListener().doStop(); } catch (Exception e) { DaemonStarter.abortSystem(e);
DaemonStarter.getLifecycleListener().doStart(); } catch (Exception e) { DaemonStarter.abortSystem(e); DaemonStarter.getLifecycleListener().doStop(); } catch (Exception e) { DaemonStarter.abortSystem(e);