Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server.destroy and client.on exit #1

Open
wactbprot opened this issue Jan 16, 2016 · 0 comments
Open

server.destroy and client.on exit #1

wactbprot opened this issue Jan 16, 2016 · 0 comments

Comments

@wactbprot
Copy link
Contributor

Hi Jonathan,

I'm currently try to work out a concept to shutdown and restart a sc-broker based system. I got the impression that I misunderstood either server.destroy() or client.on("exit", ...). Here is a minimal example:

server.js:

(function(){
  var broker = require("sc-broker")
    , server   = broker.createServer({port: 9000});

  server.on('ready', function(){
    var client  = broker.createClient({port: 9000});

    client.subscribe("shutdown", function (err){
      console.log("subscribe");
    });

    client.on('message', function (ch, val){
      if(ch == "shutdown"){
        console.log("server shutdown");
        server.destroy();
      }
    });
  });
})();

client.js

(function(){
  var broker   = require("sc-broker")
  var client  = broker.createClient({port: 9000});

  client.on('exit', function (l){
    console.log("client exit");
  });
})();

If I start $ node server.js followed by $ node client.js I would expect that a published shutdown event triggers the client exit event. However, I only get the message "server shutdown". The client process ends without "client exit".

Do you have some remarks on that. Thank you in advance
--Thomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant