Improved SystemFileLock, added tests watchdog_test & watchdog_hold_test
This commit is contained in:
parent
e746ae610c
commit
96f36d1306
|
@ -42,7 +42,22 @@
|
|||
|
||||
|
||||
$this->SystemLockResource = fopen($this->SystemLockFile, 'w+');
|
||||
if(flock($this->SystemLockResource, LOCK_EX) == false)
|
||||
$count = 0;
|
||||
$timeout_seconds = 3;
|
||||
$got_lock = true;
|
||||
while(!flock($this->SystemLockResource, LOCK_EX | LOCK_NB, $would_block))
|
||||
{
|
||||
if($would_block && $count++ < $timeout_seconds)
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$got_lock = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($got_lock == false)
|
||||
{
|
||||
fclose($this->SystemLockResource);
|
||||
$this->SystemLockResource = null;
|
||||
|
|
|
@ -48,16 +48,24 @@
|
|||
},
|
||||
{
|
||||
"required": true,
|
||||
"file": "Exceptions/FileException.php"
|
||||
},
|
||||
{
|
||||
"required": true,
|
||||
"file": "Exceptions/InvalidDataException.php"
|
||||
"file": "Exceptions/WatchDogAlreadyRunningException.php"
|
||||
},
|
||||
{
|
||||
"required": true,
|
||||
"file": "Exceptions/ConfigurationException.php"
|
||||
},
|
||||
{
|
||||
"required": true,
|
||||
"file": "Exceptions/FileNotFoundException.php"
|
||||
},
|
||||
{
|
||||
"required": true,
|
||||
"file": "Exceptions/IOException.php"
|
||||
},
|
||||
{
|
||||
"required": true,
|
||||
"file": "Utilities/Functions.php"
|
||||
},
|
||||
{
|
||||
"required": true,
|
||||
"file": "Utilities/PathFinder.php"
|
||||
|
@ -72,7 +80,7 @@
|
|||
},
|
||||
{
|
||||
"required": true,
|
||||
"file": "Objects/LaunchCondition.php"
|
||||
"file": "Objects/LunchCondition.php"
|
||||
},
|
||||
{
|
||||
"required": true,
|
||||
|
|
|
@ -9,6 +9,8 @@ MaxLogSize=28M
|
|||
[start]
|
||||
# Run HTOP, the best Linux web server ever.
|
||||
Exec=/usr/bin/htop
|
||||
Args=--verbose:--auth=netkas\:netkas:-d
|
||||
Env=GITHUB_API_KEY=foo
|
||||
Restart=always
|
||||
LogStdout=false
|
||||
ErrorExitStatus=1 23
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
require 'ppm';
|
||||
require 'net.intellivoid.ssm';
|
||||
|
||||
|
||||
$watchdog_service = new \ssm\Classes\WatchDog();
|
||||
|
||||
print('Locking SystemLockFile' . PHP_EOL);
|
||||
try
|
||||
{
|
||||
$watchdog_service->run();
|
||||
print('Success' . PHP_EOL);
|
||||
print('Holding for 10 seconds' . PHP_EOL);
|
||||
sleep(10);
|
||||
print('Done.' . PHP_EOL);
|
||||
}
|
||||
catch (\ssm\Exceptions\WatchDogAlreadyRunningException $e)
|
||||
{
|
||||
print('Failed, ' . $e->getMessage() . PHP_EOL);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
require 'ppm';
|
||||
require 'net.intellivoid.ssm';
|
||||
|
||||
|
||||
$watchdog_service = new \ssm\Classes\WatchDog();
|
||||
|
||||
print('Locking SystemLockFile' . PHP_EOL);
|
||||
try
|
||||
{
|
||||
$watchdog_service->run();
|
||||
print('Success' . PHP_EOL);
|
||||
}
|
||||
catch (\ssm\Exceptions\WatchDogAlreadyRunningException $e)
|
||||
{
|
||||
print('Failed, ' . $e->getMessage() . PHP_EOL);
|
||||
}
|
Loading…
Reference in New Issue