liip / process-manager
Provides a simple locking mechanism based on UNIX process id's written to a PID file.
Installs: 65 914
Dependents: 7
Suggesters: 0
Security: 0
Stars: 33
Watchers: 45
Forks: 4
Open Issues: 1
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2022-02-01 12:20:47 UTC
README
Provides a simple locking mechanism based on UNIX process id's written to a "PID file".
http://github.com/liip/LiipProcessManager.git
Here is a simple example
<?php use Liip\ProcessManager\ProcessManager; use Liip\ProcessManager\PidFile; // run a process in the back ground $processManager = new ProcessManager(); $pid = $processManager->execProcess('sleep 10m'); $processManager->isProcessRunning($pid) $processManager->killProcess($pid); // to set log location instead of routing it to /dev/null by default $processManager = new ProcessManager('/path/to/logfile'); $pid = $processManager->execProcess('sleep 10m'); // acquire a lock via a pid file $lock = new PidFile(new ProcessManager(), '/tmp/foobar'); $lock->acquireLock(); $pid = $lock->execProcess('sleep 10m'); // set the PID which should be locked on $lock->setPid(getmypid()); $lock->releaseLock();