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

Can you "pause" the zetta server? Or separate _run from listen? #363

Open
wooliet opened this issue Jan 10, 2018 · 2 comments
Open

Can you "pause" the zetta server? Or separate _run from listen? #363

wooliet opened this issue Jan 10, 2018 · 2 comments

Comments

@wooliet
Copy link
Contributor

wooliet commented Jan 10, 2018

I am looking for a way to "pause" the zetta server so that HTTP requests are rejected (with 503 code). The purpose is to be able to start zetta (call listen) but prevent activity until other system initialization is complete.

An alternative might be to remove call to Zetta.prototype._run from inside Zetta.prototype.listen and offer the ability to call them separately.

@wooliet
Copy link
Contributor Author

wooliet commented Jan 11, 2018

Went with a zetta app that blocks requests until a server.pubsub message comes in.

module.exports = function requestBlockApp(server) {
  var goodToGo = false;
  server.pubsub.subscribe('good-to-go', function(){
    goodToGo = true;
  });
  server.httpServer.cloud.use(function(handle) {
    handle('request',  { affinity: 'hoist' }, function(env, next){
      if(goodToGo) {
        return next(env);
      }
      if(env.argo.currentUrl.indexOf('/_initiate_peer') === 0) {
        return next(env);
      }
      env.response.statusCode = 503;
      env.response.setHeader('Content-Type', 'application/json');
      env.response.end(JSON.stringify({
        message: 'my error message'
      }));
    });
  });
};

Question

Not letting _/initiate_peer pass through causes continuous retries. Is there anything else I should be allowing through by default?

@abdul49
Copy link

abdul49 commented May 5, 2018

Hi Wooliet,
I am also looking for a same solution to pause the "zetta listen" first perform some authentication and then establish the connection.
I need help because i am new to node js and it is difficult to understand the code without explaination .

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

2 participants