Code Monkey home page Code Monkey logo

Comments (4)

fengmk2 avatar fengmk2 commented on July 3, 2024

目前需要做优雅重启,需要worker需要告诉master,请马上fork一个新进程替代我。

graceful({
  server: [ server, server.hsf ],
  worker: worker,
  error: function (err, throwErrorCount) {
    // Tell master I'm going to exit, please fork a new worker replace me.
    worker.disconnect();
    if (err.message) {
      err.message += ' (uncaughtException throw ' + throwErrorCount + ' times on pid:' + process.pid + ')';
    }
    logger.error(err);
  }
});

from pm.

aleafs avatar aleafs commented on July 3, 2024

worker什么情况下需要有这样的需求?master抓了SIGUSR1信号就是这么实现的

from pm.

fengmk2 avatar fengmk2 commented on July 3, 2024

http://nodejs.org/docs/latest/api/domain.html#domain_warning_don_t_ignore_errors

worker如果出现了未捕获异常,那么必须在一定时间后将进程退出。
但是不能马上退出,因为当前还有正在连接的请求。

所以worker需要告诉master,请马上fork一个新进程替代我。然后新的请求就转移给新的进程。
当前worker就不再接受新请求了,等一段时间后,可以认为所有已连接的请求都处理完毕了。


@fengmk2 (https://twitter.com/fengmk2)
@python发烧友 (http://weibo.com/imk2/profile)
http://fengmk2.github.com (http://fengmk2.github.com/)


记得当时年纪小/
你爱谈天,我爱笑/
有一回并肩坐在桃树下/
风在林梢鸟儿在叫/
我们不知怎样睡着了/
梦里花落知多少

On Tuesday, April 16, 2013 at 11:53 AM, aleafs wrote:

worker什么情况下需要有这样的需求?master抓了SIGUSR1信号就是这么实现的


Reply to this email directly or view it on GitHub (#32 (comment)).

from pm.

aleafs avatar aleafs commented on July 3, 2024

哦,对的

from pm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.