pe/component-process 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pe/component-process

最新稳定版本:v1.0.0

Composer 安装命令:

composer require pe/component-process

包简介

Process management based on ext-pcntl and ext-posix

关键字:

README 文档

README

The following versions of PHP are supported.

  • PHP 7.0+

Installation

To install, use composer:

php composer.phar require pe/component-process

Usage

Simple manager usage:

<?php

namespace PE\Component\Process;

// Instantiate manager
$manager = new Manager();

// Create process
$process = new Process(function (Process $process) {
    //TODO do some stuff...
});

// Execute process
$manager->fork($process);
$manager->fork($process);
$manager->fork($process);
$manager->fork($process);// <-- this will be ignored because we set max executed processes

// Wait until processes completed
$manager->wait();

Demonize any long executed code:

<?php

namespace PE\Component\Process;

use Psr\Log\NullLogger;

// Define path to pid file, must be writable by php user
$pidPath = sys_get_temp_dir() . '/daemon.pid';

// Instantiate a daemon
$daemon = new Daemon(function () {
    //TODO do some stuff...
}, $pidPath);

// Instantiate logger
$logger = new NullLogger();

// Start execution in background
$daemon->start($logger);

// You can check if daemon is still running by call:
$daemon->isRunning();

// You can break execution by call:
$daemon->stop($logger);

统计信息

  • 总下载量: 1.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-29