lockfileA class to handle a lockfile for a running process. The idea is you
create one of these for a process each time you run it. If the lockfile already exists, then
Located in /lockfile-defs.php (line 71)
lockfile
lockfile
([string $lockfilename = ""], [string $lockfiledir = "/tmp"], [integer $pid = ""])
mixed
$errorcode
= 0 (line 87)
Latest error code
mixed
$exists
= false (line 89)
True if the lockfile exists
mixed
$freezefilename
= "" (line 75)
Name of freeze lockfile to create (internal)
mixed
$freezesecs
= 0 (line 81)
Lockfile age at which we should stop trying to kill hung process
mixed
$frozen
= false (line 91)
True if the freeze lockfile exists
mixed
$killsecs
= 0 (line 79)
Lockfile age at which we should assume process is hung
mixed
$lockfilename
= "" (line 73)
Name of the lockfile to create
mixed
$lock_mins
= 0 (line 83)
Minutes process has been locked for
mixed
$messages
= "" (line 85)
Latest error message
mixed
$pid
= "" (line 77)
Process ID of process lockfile is for
Make a new lockfile handler object.
Create the lockfile. We only do this, obviously, if it doesn't already exist. If it DOES exist, then we make a lot of checks. If time-limits are set we possibly try to kill the process and remove the lockfile before creating our new one.
If we created a lockfile then we return true, and this measn the calling process should feel free to run. If we return false, then either the lock is valid, or an error condition is present, and the calling process should about/exit without running.
Remove the lockfile. Can't do this if the lock is frozen, which is deemed to require manual intervention.
Set the time limits. Some commonsense has to be applied here. You
should pick times, in mins, which are sensible according to how frequently you are going to be checking the lockfiles. If, for example you pick killmins=5 and freezemins=10 and only run this every hour, then you will never give it chance to kill a hung process between the 5 and 10 mins mark. A better choice for that would be killmins=30 freezemins=130.
Documentation generated by phpDocumentor 1.3.0RC3