0

using below code in mongoose, when i terminate the connection the console is not showing. instead i am getting some other error '(node:56588) DeprecationWarning: open() is deprecated in mongoose >= 4.11.0, use openUri() instead, or set the useMongoClient option if using connect() or createConnection(). See http://mongoosejs.com/docs/connections.html#use-mongo-client' .

 process.on('SIGINT',function(){
          mongoose.connection.close(function(){
               console.log('mongoose disconnected through app termination');
                process.exit(0);
          });
  });
  • If you are trying to "hang up" on the whole program, call `mongoose.disconnect()`. That closes ALL connections. But *"these are not the droids you are looking for"*, as the actual code thowing that particular error is either `connect()` without the specified option in the warning message, or `.createConnection()` similarly without a callback or promise resolve and merely a handler on `"open"`. Read [Connections](http://mongoosejs.com/docs/connections.html) in the documentation, as all of this is actually explained there. – Neil Lunn Nov 01 '17 at 09:16
  • i am not trying to hang up i am trying to get this console when i terminate my application – Dhiraj Sharma Nov 01 '17 at 11:35
  • SIGNIT should be called while terminating my app but its not called – Dhiraj Sharma Nov 01 '17 at 11:42
  • How are you terminating the app??? http://meinit.nl/the-3-most-important-kill-signals-on-the-linux-unix-command-line – Neil Lunn Nov 01 '17 at 11:44
  • by rs in git bash or by manually ctrl+c – Dhiraj Sharma Nov 01 '17 at 11:46
  • are there signals are only for linux – Dhiraj Sharma Nov 01 '17 at 11:48
  • This is exactly why you do not "cargo cult" code. Before you start copying someones code from a blog post or whatever you find, "understand it first". That should be the lesson here. Simply solved by realizing you are on windows and looking up that signal handling happens differently. – Neil Lunn Nov 01 '17 at 11:56
  • i figured thanks man , new to mongodb. – Dhiraj Sharma Nov 01 '17 at 13:40

0 Answers0