Home  >  Article  >  Backend Development  >  QPM-PHP multi-process development-Supervisor configuration reference

QPM-PHP multi-process development-Supervisor configuration reference

WBOY
WBOYOriginal
2016-08-08 09:29:071187browse
QPM is a PHP process management framework that can be used to simplify Daemon development. The project address is: https://github.com/Comos/qpm
As of version 0.2, QPM supports 3 Supervison modes, OneForOne MultiGroupOneForOne and TaskFactoryMode. Different modes can establish different process tree combinations, restart sub-processes, and concurrency control strategies to adapt to different application scenarios. Different modes correspond to different factory methods. For example, the creation method of OneForOne is qpmsupervisorSupervisor::oneForOne($config);OneForOnemethodqpmsupervisorSupervisor::oneForOne($config)usage scenariosall The child processes all use the same callback function or Runnable class. Configuration fields
  • *runnableCallback or runnableClass. Type callable or qpmprocessRunnable runnableCallback is the callback that performs the actual task in the child process. runnableClass is a class that performs actual tasks in the child process, and runnableCallback is a choice.

  • quantity type integer default 1 concurrent quantity.

  • maxRestartTimes type integer maximum number of restarts, used in conjunction with withInSeconds.
  • withInSeconds type integer and maxRestartTimes indicate the maximum number of restarts of the master process within the agreed time.
  • Example 1 'justDoIt', 'quantity' => 3]; $sup = qpm\supervisor\Supervisor::oneForOne($config); $sup->start(); Example 2 'Foo', 'quantity' => 5, 'maxRestartTimes'=>100, 'withInSeconds'=>10]; $sup = qpm\supervisor\Supervisor::oneForOne($config); $sup->start(); MultiGroupOneForOneMethodqpmsupervisorSupervisor::oneForOne($config)Usage scenariosMultiGroupOne ForOne is an upgraded version of OneForOne, which can manage multiple groups of OneForOne process. The configuration of MultiGroupOneForOne is an array embedded with several OneForOne configurations. TaskFactoryModeTask factory mode, tasks are generated by the specified factory method. MethodqpmsupervisorSupervisor::taskFactoryMode($config)Usage scenariosThe tasks performed by each child process are different and require different parameters, classes or Run functions, so each task is generated by the task factory . Configuration fields*factoryMethod callable is used to generate task objects or callable factory methods. factoryMethod return value can be qpmprocessRunnable or callable
  • quantity type integer default 1 concurrent quantity.

  • As of version 0.2, QPM supports 3 Supervison modes, OneForOne MultiGroupOneForOne and TaskFactoryMode. Different modes can establish different process tree combinations, restart sub-processes, and concurrency control strategies to adapt to different application scenarios. Different modes correspond to different factory methods. For example, the creation method of OneForOne is qpmsupervisorSupervisor::oneForOne($config);OneForOnemethodqpmsupervisorSupervisor::oneForOne($config)usage scenariosall The child processes all use the same callback function or Runnable class. Configuration fields
  • *runnableCallback or runnableClass. Type callable or qpmprocessRunnable runnableCallback is the callback that performs the actual task in the child process. runnableClass is a class that performs actual tasks in the child process, and runnableCallback is a choice.

  • quantity type integer default 1 concurrent quantity.

  • maxRestartTimes type integer maximum number of restarts, used in conjunction with withInSeconds.
  • withInSeconds type integer and maxRestartTimes indicate the maximum number of restarts of the master process within the agreed time.
  • Example 1 'justDoIt', 'quantity' => 3]; $sup = qpm\supervisor\Supervisor::oneForOne($config); $sup->start(); Example 2 'Foo', 'quantity' => 5, 'maxRestartTimes'=>100, 'withInSeconds'=>10]; $sup = qpm\supervisor\Supervisor::oneForOne($config); $sup->start(); MultiGroupOneForOneMethodqpmsupervisorSupervisor::oneForOne($config)Usage scenariosMultiGroupOne ForOne is an upgraded version of OneForOne, which can manage multiple groups of OneForOne process. The configuration of MultiGroupOneForOne is an array embedded with several OneForOne configurations. TaskFactoryModeTask factory mode, tasks are generated by the specified factory method. MethodqpmsupervisorSupervisor::taskFactoryMode($config)Usage scenariosThe tasks performed by each child process are different and require different parameters, classes or Run functions, so each task is generated by the task factory . Configuration fields*factoryMethod callable is used to generate task objects or callable factory methods. factoryMethod return value can be qpmprocessRunnable or callable
  • quantity type integer default 1 concurrency quantity.
  • The above introduces the QPM-PHP multi-process development-Supervisor configuration reference, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Previous article:21 Python TipsNext article:21 Python Tips