All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.scalecube.runners.Runners Maven / Gradle / Ivy

There is a newer version: 1.0.25
Show newest version
package io.scalecube.runners;

import sun.misc.Signal;
import sun.misc.SignalHandler;

public final class Runners {

  private Runners() {
    // Do not instantiate
  }

  /**
   * Listens to jvm signas SIGTERM and SIGINT and applies shutdown lambda function.
   *
   * @param runnable shutdown task
   */
  public static void onShutdown(Runnable runnable) {
    SignalHandler handler = signal -> runnable.run();
    Signal.handle(new Signal("INT"), handler);
    Signal.handle(new Signal("TERM"), handler);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy