Stopping gearman workers nicely

后端 未结 12 866
滥情空心
滥情空心 2021-01-30 04:24

I have a number of Gearman workers running constantly, saving things like records of user page views, etc. Occasionally, I\'ll update the PHP code that is used by the Gearman w

12条回答
  •  日久生厌
    2021-01-30 04:32

    Given the fact that the workers are written in PHP, it would be a good idea to recycle them on a known schedule. This can be a static amount of time since started or can be done after a certain number of jobs have been attempted.

    This essentially kills (no pun intended) two birds with one stone. You are are mitigating the potential for memory leaks, and you have a consistent way to determine when your workers will pick up on any potentially new code.

    I generally write workers such that they report their interval to stdout and/or to a logging facility so it is simple to check on where a worker is in the process.

提交回复
热议问题