How to use killable - 2 common examples

To help you get started, we’ve selected a few killable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sensu / sensu-go / dashboard / scripts / serve.js View on Github external
target: "http://localhost:8080",
    logLevel: "silent",
  }),
);

app.use(express.static(path.join(root, "build/vendor/public")));

if (process.env.NODE_ENV !== "development") {
  app.use(express.static(path.join(root, "build/lib/public")));
}

app.use(historyFallback());

app.use(devMiddlware(compiler));

const server = killable(http.createServer(app));

["SIGINT", "SIGTERM"].forEach(sig => {
  process.on(sig, () => {
    console.info(`Process Ended via ${sig}`);
    server.kill();
  });
});

server.on("error", error => {
  throw error;
});

server.on("listening", () => {
  console.log("listening on", server.address().port);
});
github pixel-point / kube-forwarder / src / renderer / store / modules / Connections.js View on Github external
async function startForward(commit, k8sForward, service, target) {
  const server = net.createServer(function(socket) {
    k8sForward.portForward(target.namespace, target.podName, [target.remotePort], socket, null, socket, 3)
    k8sForward.disconnectOnErr = false
  })

  killable(server)

  const resultPromise = new Promise((resolve) => {
    const serviceString = `Service ${getServiceLabel(service)}(${service.id})`

    server.on('error', (error) => {
      if (server.listening) {
        killServer(commit, target.localPort)
      } else {
        server.kill()
        const prettyError = netServerPrettyError(error)
        console.info(`Error while forwarding ${serviceString}: ${prettyError.message}`)
        resolve({ success: false, error: prettyError })
      }
    })

    server.listen(target.localPort, '127.0.0.1', () => {

killable

Keeps track of a server's open sockets so they can be destroyed at a moment's notice.

ISC
Latest version published 6 years ago

Package Health Score

65 / 100
Full package analysis

Popular killable functions