PHP code example of xingwenge / multi-process

1. Go to this page and download the library: Download xingwenge/multi-process library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xingwenge / multi-process example snippets


# composer lti-process && cd multi-process
# cp -r ../vendor/xingwenge/multi-process/bin/* .

// 修改demo 进程任务. redis连接配置、队列名称
# vi ./demo/redis-queue-pop.php          // redis 队列推送
# vi ./demo/redis-queue-push.php         // redis I/O阻塞,队列拉取

// 修改 config.yaml 配置文件,配置进程运行路径

// 运行demo.
# php ./multiprocessd -c config.yaml

// 推送数据到队列
# php ./demo/redis-queue-push.php

// 平滑结束
# php ./multiprocessctl -c config.yaml -s quit

// 停止
# php ./multiprocessctl -c config.yaml -s stop


settings:
  workDir: /tmp/multi-process          # 工作目录,存放进程id、日志

programs:                               
  Demo:                                 # 进程名称
    bin: /usr/local/php/bin/php         # 进程运行路径
    binArgs:                            # 参数
      - /data/www/multiprocess/bin/demo/redis-queue-pop.php
    startSecs: 3                        # 进程运行最小时长
    startRetries: 3                     # 程序运行失败重试的最大次数