Skip to content

This library has been designed with the intention of preventing the execution of multiple instances of a script.

License

Notifications You must be signed in to change notification settings

sunaoka/process-guard-php

Repository files navigation

ProcessGuard for PHP

Latest License PHP Test codecov


This library has been designed with the intention of preventing the execution of multiple instances of a script.

In the event that it is intended for use in batch processing and a script is already running, all subsequent attempts at execution can be terminated until the current process completes.

Installation

composer require sunaoka/process-guard-php

Basic Usage

use Sunaoka\ProcessGuard\Drivers\FileDriver;
use Sunaoka\ProcessGuard\LockFactory;

$driver = new FileDriver();
$factory = new LockFactory($driver);

$lock = $factory->create('Preventing Multiple Instances', ttl: 60.0);
if ($lock->acquire() === false) {
    // already running
    exit;
}

// You can do some processing

$lock->release();

About

This library has been designed with the intention of preventing the execution of multiple instances of a script.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages