mirror of
https://github.com/Yubico/yubikey-val.git
synced 2025-02-01 01:52:18 +01:00
51 lines
1.5 KiB
PHP
Executable File
51 lines
1.5 KiB
PHP
Executable File
#!/usr/bin/php -q
|
|
<?php
|
|
|
|
require_once 'ykval-synclib.php';
|
|
require_once 'ykval-config.php';
|
|
require_once "System/Daemon.php";
|
|
|
|
$appname="ykval-daemon";
|
|
|
|
System_Daemon::setOption("appName", $appname);
|
|
System_Daemon::setOption("appDescription", "Yubico val-server sync daemon");
|
|
System_Daemon::setOption("authorName", "olov@yubico.com");
|
|
System_Daemon::setOption("authorEmail", "olov@yubico.com");
|
|
|
|
|
|
System_Daemon::start(); // Spawn Deamon!
|
|
|
|
$autostart_path = System_Daemon::writeAutoRun();
|
|
if ($path){
|
|
error_log("Successfully created autostart script at " . $autostart_path);
|
|
}
|
|
error_log($appname . " started");
|
|
|
|
$servers=explode(";", $baseParams['__YKVAL_SYNC_POOL__']);
|
|
$resources=array();
|
|
$descriptors=array();
|
|
$pipes=array();
|
|
$execstring="php -d error_log='/var/log/apache2/error.log' -f ./app1.php ";
|
|
foreach($servers as $server) {
|
|
$resources[$server]=proc_open($execstring . $server, $descriptors, $pipes);
|
|
}
|
|
|
|
# Loop forever and resync
|
|
while (True) {
|
|
foreach($resources as $server=>$resource) {
|
|
$res=proc_get_status($resource);
|
|
if ($res['running']==True){
|
|
System_Daemon::log(System_Daemon::LOG_INFO, "sync server for " . $server . " status=running");
|
|
} else {
|
|
System_Daemon::log(System_Daemon::LOG_INFO, "sync server for " . $server . " not running. Trying to restart.");
|
|
$resources[$server]=proc_open($execstring . $server, $descriptors, $pipes);
|
|
}
|
|
}
|
|
sleep(60);
|
|
}
|
|
|
|
System_Daemon::stop();
|
|
?>
|
|
|
|
|