/** * Checks if the development web server is running */ function serverStatus() { $pid = $this->getPID(); if ($pid) { if (isRunning($pid)) { $this->io->done("The server is <info>running</info>\nPID: <info>{$pid}</info>"); } else { unlink($this->PID_FILE); $this->io->error("The server <red>crashed</red>", 2); } } else { $this->io->error("The server is <red>not running</red>", 1); } }
function start($aspid = false) { $unix = new unix(); $sock = new sockets(); $Masterbin = $unix->find_program("shorewall"); if (!is_file($Masterbin)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, shorewall not installed\n"; } return; } if (!$aspid) { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n"; } return; } @file_put_contents($pidfile, getmypid()); } if (isRunning()) { $timepid = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started...\n"; } return; } $cmd = "{$Masterbin} start 2>&1"; if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service\n"; } exec($cmd, $results); while (list($key, $line) = each($results)) { $line = trim($line); if ($line == null) { continue; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$line}\n"; } } if (isRunning()) { if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, success...\n"; } return; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Failed\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$cmd}\n"; } }
if (isRunning()) { stop(); start(); } exit(0); break; case 'status': if (isRunning()) { exit(0); } else { exit(3); } break; case 'force-reload': case 'reload': if (isRunning()) { stop(); start(); } else { exit(3); } exit(0); break; default: exit(0); break; } /** * Vérifie si le serveur tourne * @return boolean */
function checkParseJsonRunning() { global $config; if ($config->adsbFreq0 == "978" || $config->adsbFreq0 == "1090") { logMessage("Checking parsejson running"); $pid = 0; if (is_file("/dev/shm/upload/parsejson.pid")) { $pid = file_get_contents("/dev/shm/upload/parsejson.pid"); } /*exec("pgrep php", $pids); $found=false; foreach ($pids as $pid){ $info=file_get_contents("/proc/$pid/cmdline"); if (strpos($info, "parsejson.php")!==false){ $found==true; logMessage("Found ParseJson at PID: $pid"); } }*/ if ($pid == 0 || !isRunning($pid)) { logMessage("parsejson.php not running, starting it now!"); $pidfile = "/dev/shm/upload/parsejson.pid"; $str = "/usr/bin/php /home/pi/naboor/parsejson.php"; exec(sprintf("%s > %s 2>&1 & ", $str, "/dev/null")); } } }
//$date = new DateTime(); //if (!file_exists($filename)) { // $file = fopen($filename, 'w'); // $execution_date = $date->format('Y-m-d H:i:s'); // echo $execution_date; // fwrite($file, $execution_date); // fclose($file); //} $environment = isset($_GET['env']) ? $_GET['env'] : 'staging'; $pidroles = 'roles.pid'; $piddeploy = 'deploy.pid'; $log_file = 'log/deploy.log'; if (!isRunning($piddeploy) && !isRunning($pidroles)) { echo "executing\n"; installRoles($log_file, $piddeploy); while (isRunning($pidroles)) { sleep(1); echo 'waiting'; ob_flush(); } deploy($environment, $log_file, $piddeploy); } else { echo "already running"; } function installRoles($logFile, $pidFile) { $cmd = 'ansible-galaxy install -r /playbook/requirements.yml -p /roles &'; exec(sprintf("%s > %s 2>&1 & echo \$! >> %s", $cmd, $logFile, $pidFile)); } function deploy($environment, $logFile, $pidFile) {
<img class="disk" src="/img/disk.png" alt="Parity" /> <div><?php echo $disk_info[1]; ?> </div> <div class="size"><?php echo format_bytes($disk_size); ?> </div> <img class="ribbon" src="/img/green-ribbon.png" alt="Parity" /> <div class="disk-ref"><?php echo $disk_info[0]; ?> </div> <?php if (isRunning($disk_info[0])) { echo 'In progress'; } else { ?> <a class="redbutton button" href="/index.php/utilities/start_preclear/<?php echo $disk_info[0]; ?> /">Preclear Disk</a> <?php } ?> </div> <?php } } else { echo 'There are currently no available disks to preclear';
$result = $collection->insertOne(array("lang" => $lang, "name" => $value, "type" => $type, "insert_ts" => $current_ts)); } //var_dump($result); } } //insert running movies into database //$current_ts = date("Y/m/d h:i:sa"); foreach ($running_movies as $key => $value) { $lang = $key; foreach ($value as $key => $value) { $upcoming = isUpcoming($value, $collection); $type = "running"; if ($upcoming) { $result = $collection->updateOne(['name' => $value], ['$set' => array("lang" => $lang, "name" => $value, "type" => $type, "prev_type" => "upcoming", "notify" => "true", "update_ts" => $current_ts)], ['upsert' => true]); } else { $running = isRunning($value, $collection); if ($running) { $result = $collection->updateOne(['name' => $value], ['$set' => array("lang" => $lang, "name" => $value, "type" => $type, "update_ts" => $current_ts)], ['upsert' => true]); } else { $result = $collection->insertOne(array("lang" => $lang, "name" => $value, "type" => $type, "notify" => "true", "insert_ts" => $current_ts)); } } } } function isUpcoming($value, $collection) { $count = $collection->count(["name" => $value, "type" => "upcoming"]); if ($count > 0) { return true; } else { return false;
function reload() { if (!$GLOBALS["NOCONF"]) { build(); } if (!isRunning()) { start(true); return; } $unix = new unix(); $HAPROXY = $unix->find_program("haproxy"); $CONFIG = "/etc/haproxy/haproxy.cfg"; $PIDFILE = "/var/run/haproxy.pid"; $EXTRAOPTS = null; $pids = @implode(" ", pidsarr()); $cmd = "{$HAPROXY} -f \"{$CONFIG}\" -p {$PIDFILE} -D {$EXTRAOPTS} -sf {$pids} 2>&1"; exec($cmd, $results); while (list($num, $ligne) = each($results)) { echo "Starting......: " . date("H:i:s") . " {$GLOBALS["TITLENAME"]} {$ligne}\n"; } }
// Check if traceroute is marked as finished in the DB. If that's the case, // simply return the data and set in progress to false if ($db->tracerouteFinished($id)) { $result = $db->getTraceroute($id); $out['data'] = $result; $out['inProgress'] = false; echo json_encode($out); exit; } else { // If the traceroute command is not marked as finished, read the PID from // the file and check if it is still running $file = fopen('traceroutes/' . $id . '.pid', 'r'); $pid = fgets($file); fclose($file); $out['data'] = array(); if (isRunning($pid)) { $out['inProgress'] = true; } else { $out['inProgress'] = false; } } // At this point we know we need to get the latest data from the output file $traceFileHandle = fopen('traceroutes/' . $id . '.txt', 'r'); while (!feof($traceFileHandle)) { $line = fgets($traceFileHandle); if (strlen(trim($line)) === 0) { continue; // Ignore empty lines } /** * This part of the code parses one line of the traceroute output.
include_once './connectDatabase.php'; include_once './fileWatcherConfig.php'; include_once './loggerClass.php'; // TODO: change this to be able to process other type of input files, not just biometry $pidfile = '/tmp/DicomFileQueue.pid'; $mysqli = connectDatabase(); checkFileWatcher(); if (file_exists($pidfile)) { $currentPid = implode('', file($pidfile)); } else { $currentPid = 0; } //exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile)); if ($currentPid > 0) { echo 'CurrentPID: ' . $currentPid . "\n"; if (!isRunning($currentPid)) { saveMyPid($pidfile); $logger = new eventLogger($mysqli); processQueue($mysqli, $dicomConfig, $logger); } else { echo "Process still running! Exiting.\n"; die; } } else { saveMyPid($pidfile); processQueue($mysqli, $dicomConfig); } function checkFileWatcher() { echo "Checking file watcher status...\n"; $result = shell_exec('sudo service dicom-file-watcher status');
} } }); }); $actor = $cast_crew["Actors"]; $director = $cast_crew["Director"]; $music = $cast_crew["Music director"]; unset($cast_crew); } $upcoming = isUpcoming($movie_name, $movies_collection); $type = "running"; if ($upcoming) { $result = $movies_collection->updateOne(['name' => $movie_name], ['$set' => array("lang" => $lang, "name" => $movie_name, "type" => $type, "prev_type" => "upcoming", "booking_open_ts" => $current_ts, "notify" => "true", "update_ts" => $current_ts)], ['upsert' => true]); $events = $events_collection->insertOne(array("movie_name" => $movie_name, "event_type" => "UR", "notify" => 'true', "insert_ts" => $current_ts)); } else { $running = isRunning($movie_name, $movies_collection); if ($running) { $result = $movies_collection->updateOne(['name' => $value], ['$set' => array("lang" => $lang, "name" => $value, "type" => $type, "update_ts" => $current_ts)], ['upsert' => true]); } else { $result = $movies_collection->insertOne(array("lang" => $lang, "name" => $movie_name, "type" => $type, "id" => $movie_id, "poster_url" => $poster_url, "link" => $movie_link, "actors" => $actor, "director" => $director, "music_director" => $music, "genre" => $genre, "producer" => $producer, "release_ts" => date("Y/m/d H:i:s", strtotime($release_ts)), "notify" => "true", "disabled" => "false", "insert_ts" => $current_ts)); $events = $events_collection->insertOne(array("movie_name" => $movie_name, "event_type" => "FR", "notify" => 'true', "insert_ts" => $current_ts)); } } } } //Common functions function isUpcoming($value, $collection) { $count = $collection->count(["name" => $value, "type" => "upcoming"]); if ($count > 0) { return true;