Skip to content
官方QQ交流群
技术交流1:87208295   点此加入
技术交流2:787747122   点此加入
官网
云控制台
开放平台
关注微信公众号
代码仓库: 码云

task进程

介绍

  • 使用worker执行task
  • 使用worker写的异步任务模型

配置

配置 config/shiyun/worker_task.php

启动

sh
php think worker:task start
php think worker:task start -d
php think worker:task stop
php think worker:task start
php think worker:task start -d
php think worker:task stop

然后命令行启动 监听端口

然后调用

php
/**
 * @param array  $data 为参数数组
 * @param string $Processing 为处理数据的类或者类名字符串  
 */
worker_async_task_producer($data, $Processing)
/**
 * @param array  $data 为参数数组
 * @param string $Processing 为处理数据的类或者类名字符串  
 */
worker_async_task_producer($data, $Processing)

windows上为单进程,liunx上课设置成多进程 处理进程的类必须实现public 的 fire方法

php
public function index()
{ 
    // 你的监听地址
    $address = '127.0.0.1:19345';
    for ( $i = 0; $i < 10 ; $i++){
        $gateway_buffer = [
            'id'=>10-$i,
            'name'=>17
        ];
        $obj = "\app\index\buss\Ces";
        worker_async_task_producer($address,$gateway_buffer,$obj);
    }
    echo '成功';exit;
}
public function index()
{ 
    // 你的监听地址
    $address = '127.0.0.1:19345';
    for ( $i = 0; $i < 10 ; $i++){
        $gateway_buffer = [
            'id'=>10-$i,
            'name'=>17
        ];
        $obj = "\app\index\buss\Ces";
        worker_async_task_producer($address,$gateway_buffer,$obj);
    }
    echo '成功';exit;
}

Copyright © 2017 10yun.com | 十云提供计算服务-IPV6 | ctocode组开发