定制 leocarmo/graceful-shutdown-php 二次开发

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

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

leocarmo/graceful-shutdown-php

最新稳定版本:1.0.0

Composer 安装命令:

composer require leocarmo/graceful-shutdown-php

包简介

Graceful Shutdown for PHP

README 文档

README

Build Status Scrutinizer Code Quality Code Intelligence Status Total Downloads

Generally, a graceful shutdown is preferable in the case of any OS that saves its state. When the standard shutdown procedures are not done with these OSs, the result can be data corruption of program and operating system files. The result of the corruption can be instability, incorrect functioning or failure to boot.

For more information see this.

Composer

composer require leocarmo/graceful-shutdown-php

How to use

This is very simple, you just have to call the check method inside a while loop and the magic will happen.

use LeoCarmo\GracefulShutdown\GracefulShutdown;

$shutdown = new GracefulShutdown();

while (! $shutdown->signalReceived()) {

    echo 'Start long task...' . PHP_EOL;
    sleep(sleep(5)); // --> when a signal is sent, sleep returns the number of seconds left
    echo 'End long task...' . PHP_EOL;

}

echo 'Graceful shutdown!';

Output result with debug enabled:

Start long task...
End long task...
Start long task...
^C##################### ---> Signal received: [2]
End long task...
Graceful shutdown!

Run make run-exemple to see this in action

Roadmap

  • Tests

Credits

统计信息

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

GitHub 信息

  • Stars: 18
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固