Home

Awesome

multiprocess

1. 场景

2. 流程图

流程图

3. 安装

4. 配置实例

    'logPath'   => __DIR__ . '/log',
    'exec'      => [
        [
            'name'      => 'kcloze-test-1',
            'bin'       => '/usr/bin/php',
            'binArgs'   => [__DIR__ . '/test/test.php', 'oop', '123'],
            'workNum'   => 3,
        ],
        [
            'name'      => 'kcloze-test-2',
            'bin'       => '/usr/bin/php',
            'binArgs'   => [__DIR__ . '/test/test2.php', 'oop', '456'],
            'workNum'   => 5,
        ],
        [
            'name'      => 'kcloze-test-3',
            'bin'       => '/usr/bin/python',
            'binArgs'   => [__DIR__ . '/test/test3.py', 'oop', '369'],
            'workNum'   => 2,
        ],
    ],

5. 运行

5.1 启动

5.2 平滑停止服务,根据子进程执行时间等待所有服务停止

5.3 强制停止服务[慎用]

5.4 强制重启

5.5 监控

5.6 启动参数说明

NAME
      php multiprocess - manage multiprocess

SYNOPSIS
      php multiprocess -s command [options] -c config file path
          Manage multiprocess daemons.


WORKFLOWS


      help [command]
      Show this help, or workflow help for command.

      -s restart
      Stop, then start multiprocess master and workers.

      -s start 
      Start multiprocess master and workers.
      -s start -c ./config
      Start multiprocess with specail config file.


      -s stop
      Wait all running workers smooth exit, please check multiprocess status for a while.

      -s exit
      Kill all running workers and master PIDs.

6. 服务管理

启动和关闭服务,有两种方式:

6.1 php脚本(主进程挂了之后,需要手动启动)

./multiprocess.php start|stop|exit|restart

6.2 使用systemd管理(故障重启、开机自启动)

更多systemd介绍

1. 根据自己项目路径,修改 systemd/multiprocess.service
2. sudo cp -f systemd/multiprocess.service /etc/systemd/system/
3. sudo systemctl --system daemon-reload
4. 服务管理
#启动服务
sudo systemctl start multiprocess.service
#reload服务
sudo systemctl reload multiprocess.service
#关闭服务
sudo systemctl stop multiprocess.service

7. 系统状态

监控图

8. change log

2017-11-30

9. 感谢

10. 联系

qq群:141059677