Signaler library that provide stack for signal listeners.

Overview

Stack Signaler.

test Software License Total Downloads

Contents

Installation

composer require kafkiansky/signaler

Usage

Simple example with \SIGINT signal.

use Kafkiansky\Signaler\SeldSignalFactory;
use Psr\Log\NullLogger;

$factory = new SeldSignalFactory(new NullLogger());

$signaler = $factory->subscribe([
    \SIGINT => function () use ($worker): void {
        $worker->stop();
    }
]);

while ($signaler->isTriggered() === false) {
    //
}

The main purpose of this library is to prevent the signal listener from being replaced by the pcntl_signal function if it was previously configured by vendor code. The library carefully saves previous signal listeners and will call them after yours.

In e.g.:

use Kafkiansky\Signaler\SeldSignalFactory;
use Psr\Log\NullLogger;

pcntl_signal(\SIGINT, function (): void {
    // This function will still be called after all your listeners.
});

$factory = new SeldSignalFactory(new NullLogger());

$signaler = $factory->subscribe([
    \SIGINT => function () use ($worker): void {
        $worker->stop();
    }
]);

while ($signaler->isTriggered() === false) {
    //
}

Testing

$ composer test

License

The MIT License (MIT). See License File for more information.

You might also like...
The full-stack test project for Personnel LTD.
The full-stack test project for Personnel LTD.

personnel-ltd The full-stack test project for Personnel LTD. Clone and install composer dependencies. $ git clone [email protected]:arsovskidev/personnel

Cookbook-magento - Collection of recipes to build app stack for the Magento deployments with Chef

Magento Cookbook Collection of recipes to build app stack for the Magento deployments with Chef Installation With Berkshelf echo "cookbook 'magento',

Stack Coderunner para Moodle

Stack Coderunner para Moodle Este projeto inclui um stack de ferramentas úteis para utilização do plugin de tipo de questão Moodle chamado Coderunner.

Scotch Box is a preconfigured Vagrant Box with a full array of LAMP Stack features to get you up and running with Vagrant in no time.
Scotch Box is a preconfigured Vagrant Box with a full array of LAMP Stack features to get you up and running with Vagrant in no time.

Scotch Box is a preconfigured Vagrant Box with a full array of LAMP Stack features to get you up and running with Vagrant in no time.

:date: The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects

sabre/vobject The VObject library allows you to easily parse and manipulate iCalendar and vCard objects using PHP. The goal of the VObject library is

Small convention based CQRS library for PHP

LiteCQRS for PHP Small naming-convention based CQRS library for PHP (loosely based on LiteCQRS for C#) that relies on the MessageBus, Command, EventSo

Experimental library for forking PHP

Spork: PHP on a Fork ?php $manager = new Spork\ProcessManager(); $manager-fork(function() { // do something in another process! return 'Hel

Collection pipeline library for PHP

Knapsack Collection pipeline library for PHP Knapsack is a collection library for PHP = 5.6 that implements most of the sequence operations proposed

Releases(v0.1.0)
Owner
kafkiansky
kafkiansky
Lock library to provide serialized execution of PHP code.

Requirements | Installation | Usage | License and authors | Donations php-lock/lock This library helps executing critical code in concurrent situation

null 875 Jan 7, 2023
The FileLocator library was created to provide file locating capabilities to a larger project

File Locator A simple file locator library. Summary The FileLocator library was created to provide file locating capabilities to a larger project. It

KHerGe - Archived Projects 20 Dec 22, 2021
This package was created to provide simple way to manipulate arrays in PHP

PHP Collections This package was created to provide simple way to manipulate arrays in PHP. The package was inspired by the Laravel Collections.

Wojciech Mleczek 13 Jul 26, 2021
Provide blocks which allow positioning content within them in layouts.

Mini layouts Provide blocks which allow positioning content within them in layouts. Backdrop Installation Install and enable the module as usual. Go t

Backdrop CMS contributed projects 5 Dec 17, 2021
Uses internet-connectable temperature sensors to provide cooling/heating assist for small buildings, as well as weather data

ambient-hvac Uses internet-connectable temperature sensors to provide cooling/heating assist for houses and other small buildings, as well as weather

null 3 Nov 25, 2021
Secure package for WP CLI, built to provide an easier way of securing your WordPress installation

wp-cli/secure-command Official website: Hackthewp.com Manages common security aspects of WordPress. Supports nginx and Apache. Basic Usage This packag

Igor Hrcek 68 Dec 27, 2022
Strings Package provide a fluent, object-oriented interface for working with multibyte string

Strings Package provide a fluent, object-oriented interface for working with multibyte string, allowing you to chain multiple string operations together using a more readable syntax compared to traditional PHP strings functions.

Glowy PHP 14 Mar 12, 2022
Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files

Icinga Web 2 Fileshipper module The main purpose of this module is to extend Icinga Director using some of it's exported hooks. Based on them it offer

Icinga 25 Sep 18, 2022
Medical Master or "Medic-M" was built to reduce the hassle of buying medicine, provide medicine to the sick in a short time. It is an HTML, CSS, JAVASCRIPT and PHP based system.

Medical Master (Medic-M) | WELCOME TO Medic-M(MEDICAL MASTER) | | Introduction | Medical Master or "Medic-M" was built to reduce the hassle of buying

NILOY KANTI PAUL 5 Oct 8, 2022
A complete stack for running Symfony 5 into Docker containers using docker-compose tool and with Certbot for the HTTPS certificate.

?? Docker + PHP 7.4 + MySQL8.0 + Nginx + Certbot(HTTPS) + Symfony 5 Boilerplate ?? Edited from https://github.com/ger86/symfony-docker version -> http

null 6 Nov 9, 2022