Skip to content

linkorb/pidhelper

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

PID Helper

Software License

Total Downloads Total Downloads Total Downloads

Just a small helper class designed to allow you to easily keep track of code that is already running so that it doesn't run twice.

Forked from andrewfenn/pid-helper.

Why yet another PID helper class?

I wanted a process checker that did things properly on linux. It uses the /proc interface to see if the process is still running. On OSX it uses the ps command.

There is no windows support in this library. If you'd like to add it then please submit a pull request that does something similar to the OSX or Linux implementations.

How to install

Add the following to your composer.json file and run composer update.

    "require": {
        "linkorb/pid-helper": "0.2.0"
    }

How to use

To use it call the code as shown below. This class will check that the process id is still running or not.

<?php
use PidHelper/PidHelper;

$pidHelper = new PidHelper('/path/to/dir/', 'process.pid');

if (!$pidHelper->lock()) {
    exit("Script Running\n");
}

// .... Your code ....

// Optional
$pidHelper->unlock();

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%