function framework() { $unix = new unix(); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, Framework...\n"; } $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]: Nginx Already Artica task running PID {$pid} since {$time}mn\n"; } return; } @file_put_contents($pidfile, getmypid()); if (!is_file("/etc/artica-postfix/WORDPRESS_APPLIANCE")) { $lighttpdbin = $unix->find_program("lighttpd"); if (is_file($lighttpdbin)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, {$lighttpdbin} OK turn, to lighttpd...\n"; } return; } } if (!is_file("/etc/php5/fpm/pool.d/framework.conf")) { $php = $unix->LOCATE_PHP5_BIN(); shell_exec("{$php} /usr/share/artica-postfix/exec.php-fpm.php --build"); } if (!is_file("/etc/php5/fpm/pool.d/framework.conf")) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, Unable to stat framework settings\n"; } return; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, building framework...\n"; } $host = new nginx(47980); $host->set_proxy_disabled(); $host->set_DocumentRoot("/usr/share/artica-postfix/framework"); $host->set_framework(); $host->build_proxy(); $PID = PID_NUM(); if (!$unix->process_exists($PID)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, not started, start it...\n"; } start(true); } $kill = $unix->find_program("kill"); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, reloading PID {$PID}\n"; } shell_exec("{$kill} -HUP {$PID} >/dev/null 2>&1"); }