Eranga Kapukotuwa
Eranga Kapukotuwa

Reputation: 4962

Can not exit from node app, when using docker

CRT + C is not stopping the node app, when I run the app using docker. Following are the steps I have done. I would be very thankful for your help.

My node app.

var config  = require('./config.json');
var mongodb = require('mongodb');
var request = require('request');
var http    = require('http');

// Debug log entry when starting the daemon.
console.log("REST daemon started successfully.\n");
console.log("The daemon interval is : "+ config.queue_interval +".\n");


// Resetting failed REST calls if there are any.
if (config.reset_when_start) resetCallbacks();

// Calling processQueue with the given interval.
setInterval(setSubDaemon, config.queue_interval);
setSubDaemon();

function setSubDaemon() {
   // my code is here.
}

And my docker command for running the nodeapp is follow.

docker run --link mongo:mongo -v /home/eranga/workspace/clms/daemon:/opt -p 127.0.0.1:8087:8080 custom-node-image

Upvotes: 0

Views: 1374

Answers (2)

Sergey Korepanov
Sergey Korepanov

Reputation: 41

For node application try to add this in your bootstrap file/file where you start your server listening

process.on('SIGINT', function() {
  process.exit();
});

Upvotes: 2

Meena
Meena

Reputation: 97

If u want to exit from docker node app, use this below command CTRL + P + Q

Upvotes: 1

Related Questions