2017 © Pedro Peláez
 

library command-running

Detects if a command or process is currently running.

image

ofbeaton/command-running

Detects if a command or process is currently running.

  • Friday, August 21, 2015
  • by ofbeaton
  • Repository
  • 3 Watchers
  • 2 Stars
  • 116 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

command-running

Detects if a command or process is currently running and optionally kill it., (*1)

Latest Stable Version Build Status Dependency Status Total Downloads License, (*2)

Currently supports: - Linux - Windows, (*3)

Please note that getPids() on windows is slow (2 seconds). There may be a way to speed it up using WMI in the future., (*4)

Alternatives

If you don't need advanced features, you can use the Symfony Lock component and trait in any application, even non-symfony ones. It is actively maintained and is likely more up to date., (*5)

It supports filesystem (FlockStore), shared memory (SemaphoreStore) and even databases and Redis servers., (*6)

It does not support force claims, kills, or reports., (*7)

Updates

The project is considered in a usable state and feature complete., (*8)

This project is used in corporate applications. As such, the authors are unlikely to update it on a regular basis, but instead when the corporate applications that use it run into problems. You should expect updates in the 5-10yr range., (*9)

Issues and PRs will be monitored, and we will continue to work with the community to provide updates as they are contributed., (*10)

Installing via Composer

The recommended way to install Command Running is through Composer., (*11)

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version:, (*12)

composer.phar require ofbeaton/command-running

After installing, you can now use it in your code:, (*13)

    $pidfile = 'mypidfile.txt';
    $running = new \Ofbeaton\Command\Running($pidfile);

    $ok = $running->claimPidFile();
    if ($ok === false) {
        echo 'We are currently already running'.PHP_EOL;
        exit;
    }

    // your code

    // at the end of your program
    $running->releasePidFile();

For more detailed usage, see the Forever Example., (*14)

License

This software is distributed under the MIT License. Please see License file for more information., (*15)

The Versions

07/08 2015

0.1.0

0.1.0.0 https://github.com/ofbeaton/command-running

Detects if a command or process is currently running.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

command console pid kill