定制 dpfaffenbauer/process-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dpfaffenbauer/process-manager

Composer 安装命令:

composer require dpfaffenbauer/process-manager

包简介

Process Manager helps you to see statuses for long running Processes

README 文档

README

ARCHIVED: This will no longer be maintained!

Requirements

  • Pimcore 11

Software License

Process Manager Plugin keeps track of all your "long running jobs". It adds a native GUI and a new portlet for your Dashboard. You can also create Executables and run them with one click. (It's planned to integrate a CRON like Syntax for recurring tasks)

Plugins using Process Manager

Getting started

  • Install via composer composer require dpfaffenbauer/process-manager:^2.0
  • Enable via command-line (or inside the pimcore extension manager): bin/console pimcore:bundle:enable ProcessManagerBundle
  • Install via command-line (or inside the pimcore extension manager): bin/console pimcore:bundle:install ProcessManagerBundle
  • Reload Pimcore
  • Open Tools -> Process Manager

Integrate to your Task

Create new Process

$processFactory = $container->get('process_manager.factory.process');
$process = $processFactory->createProcess(
    sprintf(
        'Process (%s): %s',
        $date->formatLocalized('%A %d %B %Y'),
        'Special Long Running Task'
    ),                                                  //Name
    'special_task',                                     //Type
    'Message',                                          //Message Text
    100,                                                //Total Steps
    0                                                   //Current Step
);
$process->save();                                       //Save

Advance the Progress

$process->progress();
$process->save();

Finish the Progress

$process->setProgress($process->getTotal());
$process->save();

Using the Process Logger

Process Manager also provides you with the ability to Log what exactly happens in your progress.

$logger = $container->get('process_manager.logger');

//Logs a emergency message
$logger->emergency($process, 'Total of 100 entries found');

//Logs a alert message
$logger->alert($process, 'Total of 100 entries found');

//Logs a critical message
$logger->critical($process, 'Total of 100 entries found');

//Logs a error message
$logger->error($process, 'Total of 100 entries found');

//Logs a warning message
$logger->warning($process, 'Total of 100 entries found');

//Logs a notice message
$logger->notice($process, 'Total of 100 entries found');

//Logs a info message
$logger->info($process, 'Total of 100 entries found');

//Logs a debug message
$logger->debug($process, 'Total of 100 entries found');

Reports

You can also further process the log to create a pretty report. To do that, you have to create a new service and implement the interface ProcessManagerBundle\Report\ReportInterface. Import Definitions has an example implementation of that Import Definition Report

Add a new Process Type

  • Add a new Class to your Bundle and implement ``ProcessManagerBundle\Process\ProcessInterface``` Interface
  • Add a new Form Type to your Bundle and add required fields to it
  • Add a new Service with tag process_manager.process
      import_definition.process_manager.process:
          class: Wvision\Bundle\ImportDefinitionsBundle\ProcessManager\ImportDefinitionProcess
          tags:
          - { name: 'process_manager.process', type: 'importdefinition', form-type: 'Wvision\Bundle\ImportDefinitionsBundle\Form\Type\ProcessManager\ImportDefinitionsType' }
  • Thats it, done. (You still need to handle Process creation within your Bundle yourself, there is no magic behind it)

Stoppable processes

You can implement your process to be stoppable by user via the admin panel. You need to set the stoppable flag of the process to true and it's status to ProcessManagerBundle::STATUS_RUNNING for the stop button to shop up:

$process->setStoppable(true);
$process->setStatus(ProcessManagerBundle::STATUS_RUNNING);
$process->save();

Additionally, you need to implement stop logic to your process. Track the process status and stop your process if it's set to ProcessManagerBundle::STATUS_STOPPING:

$process = $this->processRepository->find($processId);
if ($process->getStatus() == ProcessManagerBundle::STATUS_STOPPING) {
    // Here goes your process stop and cleanup logic
    ...
    
    $process->setStatus(ProcessManagerBundle::STATUS_STOPPED); // remember to set the status to stopped.
    $process->save();    
}

Cleanup command

You can execute a cleanup command from the console to delete old process entries and log files. To do this on a regular basis, you can add it as a cronjob.

# delete all process entries from the database and log files older than 604800 seconds (7 days)
$ ./bin/console process-manager:cleanup-process-data
 
# delete all process entries from the database and log files older than 86400 seconds (1 days)
$ ./bin/console process-manager:cleanup-process-data --seconds=86400

# delete only process entries from the database older than 604800 seconds (7 days) and keep the log files
$ ./bin/console process-manager:cleanup-process-data --keeplogs

Copyright and license

Copyright: lineofcode.at For licensing details please visit LICENSE.md

Interface Interface Interface

dpfaffenbauer/process-manager 适用场景与选型建议

dpfaffenbauer/process-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 91.37k 次下载、GitHub Stars 达 30, 最近一次更新时间为 2016 年 11 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「pimcore」 「pimcore-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 dpfaffenbauer/process-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dpfaffenbauer/process-manager 我们能提供哪些服务?
定制开发 / 二次开发

基于 dpfaffenbauer/process-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 91.37k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 31
  • 点击次数: 20
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 30
  • Watchers: 2
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2016-11-16