Closed aprchen closed 6 years ago
Details
RequestSenderTask::class 只会创建一个
/** * Custom process * * @Process(boot=true) */ class MyProcess implements ProcessInterface { public function run(SwoftProcess $process) { $res = ProcessBuilder::create(RequestSender::NAME)->getProcess(); $res->start(); } /** * @return bool * 启动执行条件 */ public function check(): bool { return true; } } /** * Custom process * * @Process(name="RequestSender",num=2,coroutine=true) */ class RequestSender implements ProcessInterface { const NAME = "RequestSender"; public function run(SwoftProcess $process) { $process->name(self::NAME); /** @var RequestSenderTask $service */ $service = App::getBean(RequestSenderTask::class); $service->runTask(); } public function check(): bool { return true; }
@aprchen num参数只在boot目录下的父进程中有效,子进程的创建多个是通过 for($i =0, $i < 2; $i++ ) ProcessBuilder::create(RequestSender::NAME)->start()
Details
RequestSenderTask::class 只会创建一个