Generally, a graceful shutdown is preferable in the case of any OS that saves its state

Overview

Graceful Shutdown with PHP

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

You might also like...
An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods.
An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods.

OrchidTables An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods. In

Track any ip address with IP-Tracer. IP-Tracer is developed for Linux and Termux. you can retrieve any ip address information using IP-Tracer.
Track any ip address with IP-Tracer. IP-Tracer is developed for Linux and Termux. you can retrieve any ip address information using IP-Tracer.

IP-Tracer is used to track an ip address. IP-Tracer is developed for Termux and Linux based systems. you can easily retrieve ip address information using IP-Tracer. IP-Tracer use ip-api to track ip address.

Use Ray in any PHP script without requiring it in your projects.

Global Ray Use Ray in any PHP script without requiring it in your projects. Require this package globally with Composer: composer global require cuyz/

WordPlate is a wrapper around WordPress. It makes developers life easier. It is just like building any other WordPress website with themes and plugins. Just with sprinkles on top.
WordPlate is a wrapper around WordPress. It makes developers life easier. It is just like building any other WordPress website with themes and plugins. Just with sprinkles on top.

WordPlate is simply a wrapper around WordPress. It makes developers life easier. It is just like building any other WordPress website with themes and plugins. Just with sprinkles on top.

OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures  all the essential functionalities required for any enterprise.
OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures all the essential functionalities required for any enterprise.

OrangeHRM Open Source Application OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures all the essential functionalities

Algerian code generator for invoices, quotes or any commercial documents

Algerian invoice code generator The library is useful to generate code for invoices, quotes or any commercial transaction document. Goal Is to provide

A non-intrusive support form that can be displayed on any page
A non-intrusive support form that can be displayed on any page

A non-intrusive support bubble that can be displayed on any page Using this package you can quickly add a chat bubble that opens a support form on any

Enable method chaining or fluent expressions for any value and method.

PHP Pipe Operator A (hopefully) temporary solution to implement the pipe operator in PHP. Table of contents Requirements How to install How to use The

Releases(1.0.0)
Owner
Leonardo Carmo
Leonardo Carmo
Magento 2 Module Experius Page Not Found 404. This module saves all 404 url to a database table

Magento 2 Module Experius Page Not Found 404 This module saves all 404 urls to a database table. Adds an admin grid with 404s It includes a count so y

Experius 28 Dec 9, 2022
WordPress block that displays a random "powered by" message, generally meant for footers.

X3P0 Powered By A block that generates a random "Powered by" message. It is meant to replace the typical "Powered by Theme/WordPress" message in foote

X3P0 4 Nov 4, 2022
Enhancement to Magento to allow simple product prices to be used instead of the default special-case configurable product prices

Simple Configurable Products Extension For Magento This documentation applies to SCP versions 0.7 onwards. The documentation for SCP v0.6 and earlier

Simon King 288 Nov 7, 2022
QaraTMS is open source test case, test suites, test plans and test runs management tool.

QaraTMS - Open Source Test Management System QaraTMS is open source test management software for managing test suites, test cases, test plans, test ru

Alex H 29 Dec 22, 2022
Test case to reproduce a PHP segmentation fault involving Xdebug, streams, and dates

The code in this repository causes a segmentation fault when run with PHP 8.0.6 on Fedora 33. This issue was originally reported to the Xdebug project

Matthew Turland 0 Jul 31, 2021
This project has reached its end-of-life (EOL).

EOL Notice This project has reached its end-of-life (EOL). README Requirements The supported Magento version is 1.9.x Features ajax navigation using h

Catalin Ciobanu 136 Apr 2, 2022
Reset UI Bookmarks allows admin users to reset their own UI bookmarks such as state of filters, column positions and applied sorting ( e.g Sales > Orders ).

Reset Ui Bookmarks Reset UI Bookmarks becomes an invaluable tool while working daily in the admin panel, especially on Magento® instances with a large

Magenizr 23 Oct 19, 2022
A Finite State Machine System based on Chapter 3.1 of Game Programming Gems 1 by Eric Dybsand

A Finite State Machine System based on Chapter 3.1 of Game Programming Gems 1 by Eric Dybsand,Written by Roberto Cezar Bianchini, July 2010 ported to php by MrFerrys.

null 4 Apr 18, 2022
yform 4 usability addon (temporary until yform gets its own)

massif_usability Package für REDAXO CMS >= 5.10.0 temporäres Ersatz-Plugin für yform_usability für yform >=4 – bietet ähnliche Funktionalität wie yfor

Yves Torres 6 Mar 4, 2022
XState - A State Machine for PHP

XState - A State Machine for PHP State machine library to play with any complex behavior of your PHP objects Installation You can install the package

Mouad Ziani 68 Dec 18, 2022