コード例 #1
0
 function oneLoop($pause = True)
 {
     if (file_exists($this->command_file())) {
         $text = file_get_contents($this->command_file());
         $command_lines = split("\n", $text);
         $command = $command_lines[0];
         if ($command == "stop") {
             return False;
         }
     }
     $delay = $pause ? 1 : 0;
     System_Daemon::iterate($delay);
     return True;
 }
コード例 #2
0
ファイル: bmDaemon.php プロジェクト: NickMitin/FuckFrameworks
 public function execute()
 {
     ob_start();
     if ($this->runmodes['help'] == true) {
         echo 'Usage: ' . $argv[0] . ' [runmodes]' . "\n";
         echo 'Available runmodes:' . "\n";
         foreach ($this->runmodes as $runmode) {
             echo ' --' . $runmode . "\n";
         }
         die;
     }
     System_Daemon::setOptions($this->options);
     if (!$this->runmodes['no-daemon']) {
         System_Daemon::start();
     }
     if (!$this->runmodes['write-initd']) {
         System_Daemon::info('not writing an init.d script this time');
     } else {
         if (($initd_location = System_Daemon::writeAutoRun()) === false) {
             System_Daemon::notice('unable to write init.d script');
         } else {
             System_Daemon::info('sucessfully written startup script: %s', $initd_location);
         }
     }
     $this->application->dataLink->disconnect();
     $this->application->dataLink->connect();
     while (!System_Daemon::isDying() && $this->status == self::RUN) {
         $this->process();
         System_Daemon::iterate($this->ownOptions['sleep']);
         $output = ob_get_contents();
         if ($output != '') {
             System_Daemon::info($output);
         }
         ob_clean();
     }
 }
コード例 #3
0
    //         'daemon" mode';
    // System_Daemon::info('{appName}  in %s %s/300', $a, $b);
    try {
        require_once 'lib/php/beanstalkd/ColaMensajes.php';
        $colaMensajes = new ColaMensajes("transformarvideos");
        $job = $colaMensajes->pop();
        if ($job == "") {
            //Time out
            //System_Daemon::info("Time out!");
        } else {
            $json = $job->getData();
            require_once 'modulos/videos/controladores/videoControlador.php';
            if (transformar($json)) {
                System_Daemon::notice('Video transformado correctamente');
            } else {
                System_Daemon::info("ERROR! el resultado de la transformación no es cero");
            }
            $colaMensajes->deleteJob($job);
        }
    } catch (Exception $e) {
        System_Daemon::info('ERROR! %s', $e->getMessage());
    }
    if (!$runningOkay) {
        System_Daemon::err('parseLog() produced an error, ' . 'so this will be my last run');
    }
    // Relax the system by sleeping for a little bit iterate also clears statcache
    System_Daemon::iterate(2);
}
// Shut down the daemon nicely
// This is ignored if the class is actually running in the foreground
System_Daemon::stop();
コード例 #4
0
    $JPYs = floatval($block["JPY"]["sell"]);
    $PLNb = floatval($block["PLN"]["buy"]);
    $PLNs = floatval($block["PLN"]["sell"]);
    $GBPb = floatval($block["GBP"]["buy"]);
    $GBPs = floatval($block["GBP"]["sell"]);
    $SEKb = floatval($block["SEK"]["buy"]);
    $SEKs = floatval($block["SEK"]["sell"]);
    $NZDb = floatval($block["NZD"]["buy"]);
    $NZDs = floatval($block["NZD"]["sell"]);
    $BRLb = floatval($block["BRL"]["buy"]);
    $BRLs = floatval($block["BRL"]["sell"]);
    $RUBb = floatval($block["RUB"]["buy"]);
    $RUBs = floatval($block["RUB"]["sell"]);
    $time = time();
    $result = $mysqli->query("SELECT MAX(id) as max  FROM worldbitcoin");
    $maxnum = 0;
    if ($result) {
        while ($row = $result->fetch_object()) {
            $num = $row->max;
            $maxnum = $num + 1;
        }
    } else {
        $maxnum = 1;
    }
    $stmt = $mysqli->prepare("INSERT INTO worldbitcoin(id,  USDs,           \n\n  USDb,           \n\n  ISKs,           \n\n  ISKb,           \n\n  HKDs,           \n\n  HKDb,           \n\n  TWDs,           \n\n  TWDb,           \n\n  CHFs,           \n\n  CHFb,           \n\n  EURs,           \n\n  EURb,           \n\n  DKKs,           \n\n  DKKb,           \n\n  CLPs,           \n\n  CLPb,           \n\n  CADs,           \n\n  CADb,           \n\n  CNYs,           \n\n  CNYb,           \n\n  THBs,           \n\n  THBb,           \n\n  AUDs,           \n\n  AUDb,           \n\n  SGDs,           \n\n  SGDb,           \n\n  KRWs,           \n\n  KRWb,           \n\n  JPYs,           \n\n  JPYb,           \n\n  PLNs,           \n\n  PLNb,           \n\n  GBPs,           \n\n  GBPb,           \n\n  SEKs,           \n\n  SEKb,           \n\n  NZDs,           \n\n  NZDb,           \n\n  BRLs,           \n\n  BRLb,           \n\n  RUBs,           \n\n  RUBb,           \n\n  date       )\n\nvalues(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
    $stmt->bind_param('iddddddddddddddddddddddddddddddddddddddddddi', $maxnum, $USDb, $USDs, $ISKb, $ISKs, $HKDb, $HKDs, $TWDb, $TWDs, $CHFb, $CHFs, $EURb, $EURs, $DKKb, $DKKs, $CLPb, $CLPs, $CADb, $CADs, $CNYb, $CNYs, $THBb, $THBs, $AUDb, $AUDs, $SGDb, $SGDs, $KRWb, $KRWs, $JPYb, $JPYs, $PLNb, $PLNs, $GBPb, $GBPs, $SEKb, $SEKs, $NZDb, $NZDs, $BRLb, $BRLs, $RUBb, $RUBs, $time);
    $stmt->execute();
    //Get Blockchain Data per 15 minitus.Limit This.
    System_Daemon::iterate(900);
}
System_Daemon::stop();
コード例 #5
0
<?php

require_once "../System/Daemon.php";
System_Daemon::setOption("appName", "leakplugger");
System_Daemon::start();
$last = 0;
while (!System_Daemon::isDying()) {
    $mem = memory_get_peak_usage();
    $use = $mem - $last;
    if ($use >= 0) {
        $use = '+' . $use;
    }
    System_Daemon::info("test");
    echo "debug: memory_get_peak_usage: " . $use . "\n";
    $last = $mem;
    System_Daemon::iterate(1);
}
コード例 #6
0
         }
         array_push($options, "RRA:AVERAGE:0.5:1:17280");
         array_push($options, "RRA:AVERAGE:0.5:12:86400");
         array_push($options, "RRA:AVERAGE:0.5:720:8760");
         //print_r($options);
         $ret = rrd_create($filename, $options);
         // File erzeugen
         if (!$ret) {
             //echo "<b>Creation error: </b>".rrd_error()."\n";
         }
     }
     $w++;
 }
 //	sleep(3);
 gc_enable();
 System_Daemon::iterate(3);
 // check ob ein rrd File in der Datenbanck gelöscht wurde.
 mysql_free_result($result);
 $files1 = array();
 $files2 = array();
 if ($handle = opendir('https/rrd')) {
     // namen aus dem rrd verzeichniss auslesen
     while (false !== ($file = readdir($handle))) {
         if ($file != "." && $file != "..") {
             array_push($files1, $file);
         }
     }
     closedir($handle);
 }
 mysql_connect($hostname, $username, $password);
 // namen aus der Datenbanck auslesen