Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

692 lignes
20KB

  1. <?php
  2. use Friendica\App;
  3. use Friendica\Core\Config;
  4. if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
  5. $directory = dirname($_SERVER["argv"][0]);
  6. if (substr($directory, 0, 1) != "/")
  7. $directory = $_SERVER["PWD"]."/".$directory;
  8. $directory = realpath($directory."/..");
  9. chdir($directory);
  10. }
  11. require_once("boot.php");
  12. function poller_run($argv, $argc){
  13. global $a, $db;
  14. if(is_null($a)) {
  15. $a = new App;
  16. }
  17. if(is_null($db)) {
  18. @include(".htconfig.php");
  19. require_once("include/dba.php");
  20. $db = new dba($db_host, $db_user, $db_pass, $db_data);
  21. unset($db_host, $db_user, $db_pass, $db_data);
  22. };
  23. Config::load();
  24. // Quit when in maintenance
  25. if (Config::get('system', 'maintenance', true)) {
  26. return;
  27. }
  28. $a->set_baseurl(Config::get('system', 'url'));
  29. load_hooks();
  30. $a->start_process();
  31. if ($a->min_memory_reached()) {
  32. return;
  33. }
  34. if (poller_max_connections_reached()) {
  35. return;
  36. }
  37. if ($a->maxload_reached()) {
  38. return;
  39. }
  40. if(($argc <= 1) OR ($argv[1] != "no_cron")) {
  41. poller_run_cron();
  42. }
  43. if ($a->max_processes_reached()) {
  44. return;
  45. }
  46. // Checking the number of workers
  47. if (poller_too_much_workers()) {
  48. poller_kill_stale_workers();
  49. return;
  50. }
  51. $starttime = time();
  52. while ($r = poller_worker_process()) {
  53. // Check free memory
  54. if ($a->min_memory_reached()) {
  55. return;
  56. }
  57. // Count active workers and compare them with a maximum value that depends on the load
  58. if (poller_too_much_workers()) {
  59. return;
  60. }
  61. if (!poller_execute($r[0])) {
  62. return;
  63. }
  64. // Quit the poller once every hour
  65. if (time() > ($starttime + 3600))
  66. return;
  67. }
  68. }
  69. /**
  70. * @brief Execute a worker entry
  71. *
  72. * @param array $queue Workerqueue entry
  73. *
  74. * @return boolean "true" if further processing should be stopped
  75. */
  76. function poller_execute($queue) {
  77. $a = get_app();
  78. $mypid = getmypid();
  79. // Quit when in maintenance
  80. if (Config::get('system', 'maintenance', true)) {
  81. return false;
  82. }
  83. // Constantly check the number of parallel database processes
  84. if ($a->max_processes_reached()) {
  85. return false;
  86. }
  87. // Constantly check the number of available database connections to let the frontend be accessible at any time
  88. if (poller_max_connections_reached()) {
  89. return false;
  90. }
  91. $upd = q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = %d WHERE `id` = %d AND `pid` = 0",
  92. dbesc(datetime_convert()),
  93. intval($mypid),
  94. intval($queue["id"]));
  95. if (!$upd) {
  96. logger("Couldn't update queue entry ".$queue["id"]." - skip this execution", LOGGER_DEBUG);
  97. q("COMMIT");
  98. return true;
  99. }
  100. // Assure that there are no tasks executed twice
  101. $id = q("SELECT `pid`, `executed` FROM `workerqueue` WHERE `id` = %d", intval($queue["id"]));
  102. if (!$id) {
  103. logger("Queue item ".$queue["id"]." vanished - skip this execution", LOGGER_DEBUG);
  104. q("COMMIT");
  105. return true;
  106. } elseif ((strtotime($id[0]["executed"]) <= 0) OR ($id[0]["pid"] == 0)) {
  107. logger("Entry for queue item ".$queue["id"]." wasn't stored - skip this execution", LOGGER_DEBUG);
  108. q("COMMIT");
  109. return true;
  110. } elseif ($id[0]["pid"] != $mypid) {
  111. logger("Queue item ".$queue["id"]." is to be executed by process ".$id[0]["pid"]." and not by me (".$mypid.") - skip this execution", LOGGER_DEBUG);
  112. q("COMMIT");
  113. return true;
  114. }
  115. q("COMMIT");
  116. $argv = json_decode($queue["parameter"]);
  117. // Check for existance and validity of the include file
  118. $include = $argv[0];
  119. if (!validate_include($include)) {
  120. logger("Include file ".$argv[0]." is not valid!");
  121. q("DELETE FROM `workerqueue` WHERE `id` = %d", intval($queue["id"]));
  122. return true;
  123. }
  124. require_once($include);
  125. $funcname = str_replace(".php", "", basename($argv[0]))."_run";
  126. if (function_exists($funcname)) {
  127. poller_exec_function($queue, $funcname, $argv);
  128. q("DELETE FROM `workerqueue` WHERE `id` = %d", intval($queue["id"]));
  129. } else {
  130. logger("Function ".$funcname." does not exist");
  131. }
  132. return true;
  133. }
  134. /**
  135. * @brief Execute a function from the queue
  136. *
  137. * @param array $queue Workerqueue entry
  138. * @param string $funcname name of the function
  139. * @param array $argv Array of values to be passed to the function
  140. */
  141. function poller_exec_function($queue, $funcname, $argv) {
  142. $a = get_app();
  143. $mypid = getmypid();
  144. $argc = count($argv);
  145. logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." ".$queue["parameter"]);
  146. $stamp = (float)microtime(true);
  147. // We use the callstack here to analyze the performance of executed worker entries.
  148. // For this reason the variables have to be initialized.
  149. if (Config::get("system", "profiler")) {
  150. $a->performance["start"] = microtime(true);
  151. $a->performance["database"] = 0;
  152. $a->performance["database_write"] = 0;
  153. $a->performance["network"] = 0;
  154. $a->performance["file"] = 0;
  155. $a->performance["rendering"] = 0;
  156. $a->performance["parser"] = 0;
  157. $a->performance["marktime"] = 0;
  158. $a->performance["markstart"] = microtime(true);
  159. $a->callstack = array();
  160. }
  161. // For better logging create a new process id for every worker call
  162. // But preserve the old one for the worker
  163. $old_process_id = $a->process_id;
  164. $a->process_id = uniqid("wrk", true);
  165. $funcname($argv, $argc);
  166. $a->process_id = $old_process_id;
  167. $duration = number_format(microtime(true) - $stamp, 3);
  168. if ($duration > 3600) {
  169. logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 1 hour (".round($duration/60, 3).")", LOGGER_DEBUG);
  170. } elseif ($duration > 600) {
  171. logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 10 minutes (".round($duration/60, 3).")", LOGGER_DEBUG);
  172. } elseif ($duration > 300) {
  173. logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 5 minutes (".round($duration/60, 3).")", LOGGER_DEBUG);
  174. } elseif ($duration > 120) {
  175. logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 2 minutes (".round($duration/60, 3).")", LOGGER_DEBUG);
  176. }
  177. logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - done in ".$duration." seconds.");
  178. // Write down the performance values into the log
  179. if (Config::get("system", "profiler")) {
  180. $duration = microtime(true)-$a->performance["start"];
  181. if (Config::get("rendertime", "callstack")) {
  182. if (isset($a->callstack["database"])) {
  183. $o = "\nDatabase Read:\n";
  184. foreach ($a->callstack["database"] AS $func => $time) {
  185. $time = round($time, 3);
  186. if ($time > 0)
  187. $o .= $func.": ".$time."\n";
  188. }
  189. }
  190. if (isset($a->callstack["database_write"])) {
  191. $o .= "\nDatabase Write:\n";
  192. foreach ($a->callstack["database_write"] AS $func => $time) {
  193. $time = round($time, 3);
  194. if ($time > 0)
  195. $o .= $func.": ".$time."\n";
  196. }
  197. }
  198. if (isset($a->callstack["network"])) {
  199. $o .= "\nNetwork:\n";
  200. foreach ($a->callstack["network"] AS $func => $time) {
  201. $time = round($time, 3);
  202. if ($time > 0)
  203. $o .= $func.": ".$time."\n";
  204. }
  205. }
  206. } else {
  207. $o = '';
  208. }
  209. logger("ID ".$queue["id"].": ".$funcname.": ".sprintf("DB: %s/%s, Net: %s, I/O: %s, Other: %s, Total: %s".$o,
  210. number_format($a->performance["database"] - $a->performance["database_write"], 2),
  211. number_format($a->performance["database_write"], 2),
  212. number_format($a->performance["network"], 2),
  213. number_format($a->performance["file"], 2),
  214. number_format($duration - ($a->performance["database"] + $a->performance["network"] + $a->performance["file"]), 2),
  215. number_format($duration, 2)),
  216. LOGGER_DEBUG);
  217. }
  218. $cooldown = Config::get("system", "worker_cooldown", 0);
  219. if ($cooldown > 0) {
  220. logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - in cooldown for ".$cooldown." seconds");
  221. sleep($cooldown);
  222. }
  223. }
  224. /**
  225. * @brief Checks if the number of database connections has reached a critical limit.
  226. *
  227. * @return bool Are more than 3/4 of the maximum connections used?
  228. */
  229. function poller_max_connections_reached() {
  230. // Fetch the max value from the config. This is needed when the system cannot detect the correct value by itself.
  231. $max = Config::get("system", "max_connections");
  232. // Fetch the percentage level where the poller will get active
  233. $maxlevel = Config::get("system", "max_connections_level", 75);
  234. if ($max == 0) {
  235. // the maximum number of possible user connections can be a system variable
  236. $r = q("SHOW VARIABLES WHERE `variable_name` = 'max_user_connections'");
  237. if ($r)
  238. $max = $r[0]["Value"];
  239. // Or it can be granted. This overrides the system variable
  240. $r = q("SHOW GRANTS");
  241. if ($r)
  242. foreach ($r AS $grants) {
  243. $grant = array_pop($grants);
  244. if (stristr($grant, "GRANT USAGE ON"))
  245. if (preg_match("/WITH MAX_USER_CONNECTIONS (\d*)/", $grant, $match))
  246. $max = $match[1];
  247. }
  248. }
  249. // If $max is set we will use the processlist to determine the current number of connections
  250. // The processlist only shows entries of the current user
  251. if ($max != 0) {
  252. $r = q("SHOW PROCESSLIST");
  253. if (!dbm::is_result($r))
  254. return false;
  255. $used = count($r);
  256. logger("Connection usage (user values): ".$used."/".$max, LOGGER_DEBUG);
  257. $level = ($used / $max) * 100;
  258. if ($level >= $maxlevel) {
  259. logger("Maximum level (".$maxlevel."%) of user connections reached: ".$used."/".$max);
  260. return true;
  261. }
  262. }
  263. // We will now check for the system values.
  264. // This limit could be reached although the user limits are fine.
  265. $r = q("SHOW VARIABLES WHERE `variable_name` = 'max_connections'");
  266. if (!$r)
  267. return false;
  268. $max = intval($r[0]["Value"]);
  269. if ($max == 0)
  270. return false;
  271. $r = q("SHOW STATUS WHERE `variable_name` = 'Threads_connected'");
  272. if (!$r)
  273. return false;
  274. $used = intval($r[0]["Value"]);
  275. if ($used == 0)
  276. return false;
  277. logger("Connection usage (system values): ".$used."/".$max, LOGGER_DEBUG);
  278. $level = $used / $max * 100;
  279. if ($level < $maxlevel)
  280. return false;
  281. logger("Maximum level (".$level."%) of system connections reached: ".$used."/".$max);
  282. return true;
  283. }
  284. /**
  285. * @brief fix the queue entry if the worker process died
  286. *
  287. */
  288. function poller_kill_stale_workers() {
  289. $r = q("SELECT `pid`, `executed`, `priority`, `parameter` FROM `workerqueue` WHERE `executed` > '%s'", dbesc(NULL_DATE));
  290. if (!dbm::is_result($r)) {
  291. // No processing here needed
  292. return;
  293. }
  294. foreach ($r AS $pid) {
  295. if (!posix_kill($pid["pid"], 0)) {
  296. q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = 0 WHERE `pid` = %d",
  297. dbesc(NULL_DATE), intval($pid["pid"]));
  298. } else {
  299. // Kill long running processes
  300. // Check if the priority is in a valid range
  301. if (!in_array($pid["priority"], array(PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE)))
  302. $pid["priority"] = PRIORITY_MEDIUM;
  303. // Define the maximum durations
  304. $max_duration_defaults = array(PRIORITY_CRITICAL => 360, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180, PRIORITY_NEGLIGIBLE => 360);
  305. $max_duration = $max_duration_defaults[$pid["priority"]];
  306. $argv = json_decode($pid["parameter"]);
  307. $argv[0] = basename($argv[0]);
  308. // How long is the process already running?
  309. $duration = (time() - strtotime($pid["executed"])) / 60;
  310. if ($duration > $max_duration) {
  311. logger("Worker process ".$pid["pid"]." (".implode(" ", $argv).") took more than ".$max_duration." minutes. It will be killed now.");
  312. posix_kill($pid["pid"], SIGTERM);
  313. // We killed the stale process.
  314. // To avoid a blocking situation we reschedule the process at the beginning of the queue.
  315. // Additionally we are lowering the priority.
  316. q("UPDATE `workerqueue` SET `executed` = '%s', `created` = '%s',
  317. `priority` = %d, `pid` = 0 WHERE `pid` = %d",
  318. dbesc(NULL_DATE),
  319. dbesc(datetime_convert()),
  320. intval(PRIORITY_NEGLIGIBLE),
  321. intval($pid["pid"]));
  322. } else {
  323. logger("Worker process ".$pid["pid"]." (".implode(" ", $argv).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG);
  324. }
  325. }
  326. }
  327. }
  328. /**
  329. * @brief Checks if the number of active workers exceeds the given limits
  330. *
  331. * @return bool Are there too much workers running?
  332. */
  333. function poller_too_much_workers() {
  334. $queues = Config::get("system", "worker_queues", 4);
  335. $maxqueues = $queues;
  336. $active = poller_active_workers();
  337. // Decrease the number of workers at higher load
  338. $load = current_load();
  339. if($load) {
  340. $maxsysload = intval(Config::get("system", "maxloadavg", 50));
  341. $maxworkers = $queues;
  342. // Some magical mathemathics to reduce the workers
  343. $exponent = 3;
  344. $slope = $maxworkers / pow($maxsysload, $exponent);
  345. $queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
  346. $s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` <= '%s'", dbesc(NULL_DATE));
  347. $entries = $s[0]["total"];
  348. if (Config::get("system", "worker_fastlane", false) AND ($queues > 0) AND ($entries > 0) AND ($active >= $queues)) {
  349. $s = q("SELECT `priority` FROM `workerqueue` WHERE `executed` <= '%s' ORDER BY `priority` LIMIT 1", dbesc(NULL_DATE));
  350. $top_priority = $s[0]["priority"];
  351. $s = q("SELECT `id` FROM `workerqueue` WHERE `priority` <= %d AND `executed` > '%s' LIMIT 1",
  352. intval($top_priority), dbesc(NULL_DATE));
  353. $high_running = dbm::is_result($s);
  354. if (!$high_running AND ($top_priority > PRIORITY_UNDEFINED) AND ($top_priority < PRIORITY_NEGLIGIBLE)) {
  355. logger("There are jobs with priority ".$top_priority." waiting but none is executed. Open a fastlane.", LOGGER_DEBUG);
  356. $queues = $active + 1;
  357. }
  358. }
  359. // Create a list of queue entries grouped by their priority
  360. $running = array(PRIORITY_CRITICAL => 0,
  361. PRIORITY_HIGH => 0,
  362. PRIORITY_MEDIUM => 0,
  363. PRIORITY_LOW => 0,
  364. PRIORITY_NEGLIGIBLE => 0);
  365. $r = q("SELECT COUNT(*) AS `running`, `priority` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` GROUP BY `priority`");
  366. if (dbm::is_result($r))
  367. foreach ($r AS $process)
  368. $running[$process["priority"]] = $process["running"];
  369. $processlist = "";
  370. $r = q("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` GROUP BY `priority`");
  371. if (dbm::is_result($r))
  372. foreach ($r as $entry) {
  373. if ($processlist != "")
  374. $processlist .= ", ";
  375. $processlist .= $entry["priority"].":".$running[$entry["priority"]]."/".$entry["entries"];
  376. }
  377. logger("Load: ".$load."/".$maxsysload." - processes: ".$active."/".$entries." (".$processlist.") - maximum: ".$queues."/".$maxqueues, LOGGER_DEBUG);
  378. // Are there fewer workers running as possible? Then fork a new one.
  379. if (!Config::get("system", "worker_dont_fork") AND ($queues > ($active + 1)) AND ($entries > 1)) {
  380. logger("Active workers: ".$active."/".$queues." Fork a new worker.", LOGGER_DEBUG);
  381. $args = array("include/poller.php", "no_cron");
  382. $a = get_app();
  383. $a->proc_run($args);
  384. }
  385. }
  386. return($active >= $queues);
  387. }
  388. /**
  389. * @brief Returns the number of active poller processes
  390. *
  391. * @return integer Number of active poller processes
  392. */
  393. function poller_active_workers() {
  394. $workers = q("SELECT COUNT(*) AS `processes` FROM `process` WHERE `command` = 'poller.php'");
  395. return($workers[0]["processes"]);
  396. }
  397. /**
  398. * @brief Check if we should pass some slow processes
  399. *
  400. * When the active processes of the highest priority are using more than 2/3
  401. * of all processes, we let pass slower processes.
  402. *
  403. * @param string $highest_priority Returns the currently highest priority
  404. * @return bool We let pass a slower process than $highest_priority
  405. */
  406. function poller_passing_slow(&$highest_priority) {
  407. $highest_priority = 0;
  408. $r = q("SELECT `priority`
  409. FROM `process`
  410. INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`");
  411. // No active processes at all? Fine
  412. if (!dbm::is_result($r))
  413. return(false);
  414. $priorities = array();
  415. foreach ($r AS $line)
  416. $priorities[] = $line["priority"];
  417. // Should not happen
  418. if (count($priorities) == 0)
  419. return(false);
  420. $highest_priority = min($priorities);
  421. // The highest process is already the slowest one?
  422. // Then we quit
  423. if ($highest_priority == PRIORITY_NEGLIGIBLE)
  424. return(false);
  425. $high = 0;
  426. foreach ($priorities AS $priority)
  427. if ($priority == $highest_priority)
  428. ++$high;
  429. logger("Highest priority: ".$highest_priority." Total processes: ".count($priorities)." Count high priority processes: ".$high, LOGGER_DEBUG);
  430. $passing_slow = (($high/count($priorities)) > (2/3));
  431. if ($passing_slow)
  432. logger("Passing slower processes than priority ".$highest_priority, LOGGER_DEBUG);
  433. return($passing_slow);
  434. }
  435. /**
  436. * @brief Returns the next worker process
  437. *
  438. * @return string SQL statement
  439. */
  440. function poller_worker_process() {
  441. q("START TRANSACTION;");
  442. // Check if we should pass some low priority process
  443. $highest_priority = 0;
  444. if (poller_passing_slow($highest_priority)) {
  445. // Are there waiting processes with a higher priority than the currently highest?
  446. $r = q("SELECT * FROM `workerqueue`
  447. WHERE `executed` <= '%s' AND `priority` < %d
  448. ORDER BY `priority`, `created` LIMIT 1",
  449. dbesc(NULL_DATE),
  450. intval($highest_priority));
  451. if (dbm::is_result($r)) {
  452. return $r;
  453. }
  454. // Give slower processes some processing time
  455. $r = q("SELECT * FROM `workerqueue`
  456. WHERE `executed` <= '%s' AND `priority` > %d
  457. ORDER BY `priority`, `created` LIMIT 1",
  458. dbesc(NULL_DATE),
  459. intval($highest_priority));
  460. }
  461. // If there is no result (or we shouldn't pass lower processes) we check without priority limit
  462. if (($highest_priority == 0) OR !dbm::is_result($r)) {
  463. $r = q("SELECT * FROM `workerqueue` WHERE `executed` <= '%s' ORDER BY `priority`, `created` LIMIT 1", dbesc(NULL_DATE));
  464. }
  465. return $r;
  466. }
  467. /**
  468. * @brief Call the front end worker
  469. */
  470. function call_worker() {
  471. if (!Config::get("system", "frontend_worker")) {
  472. return;
  473. }
  474. $url = App::get_baseurl()."/worker";
  475. fetch_url($url, false, $redirects, 1);
  476. }
  477. /**
  478. * @brief Call the front end worker if there aren't any active
  479. */
  480. function call_worker_if_idle() {
  481. if (!Config::get("system", "frontend_worker")) {
  482. return;
  483. }
  484. // Do we have "proc_open"? Then we can fork the poller
  485. if (function_exists("proc_open")) {
  486. // When was the last time that we called the worker?
  487. // Less than one minute? Then we quit
  488. if ((time() - Config::get("system", "worker_started")) < 60) {
  489. return;
  490. }
  491. set_config("system", "worker_started", time());
  492. // Do we have enough running workers? Then we quit here.
  493. if (poller_too_much_workers()) {
  494. // Cleaning dead processes
  495. poller_kill_stale_workers();
  496. get_app()->remove_inactive_processes();
  497. return;
  498. }
  499. poller_run_cron();
  500. logger('Call poller', LOGGER_DEBUG);
  501. $args = array("include/poller.php", "no_cron");
  502. $a = get_app();
  503. $a->proc_run($args);
  504. return;
  505. }
  506. // We cannot execute background processes.
  507. // We now run the processes from the frontend.
  508. // This won't work with long running processes.
  509. poller_run_cron();
  510. clear_worker_processes();
  511. $workers = q("SELECT COUNT(*) AS `processes` FROM `process` WHERE `command` = 'worker.php'");
  512. if ($workers[0]["processes"] == 0) {
  513. call_worker();
  514. }
  515. }
  516. /**
  517. * @brief Removes long running worker processes
  518. */
  519. function clear_worker_processes() {
  520. $timeout = Config::get("system", "frontend_worker_timeout", 10);
  521. /// @todo We should clean up the corresponding workerqueue entries as well
  522. q("DELETE FROM `process` WHERE `created` < '%s' AND `command` = 'worker.php'",
  523. dbesc(datetime_convert('UTC','UTC',"now - ".$timeout." minutes")));
  524. }
  525. /**
  526. * @brief Runs the cron processes
  527. */
  528. function poller_run_cron() {
  529. logger('Add cron entries', LOGGER_DEBUG);
  530. // Check for spooled items
  531. proc_run(PRIORITY_HIGH, "include/spool_post.php");
  532. // Run the cron job that calls all other jobs
  533. proc_run(PRIORITY_MEDIUM, "include/cron.php");
  534. // Run the cronhooks job separately from cron for being able to use a different timing
  535. proc_run(PRIORITY_MEDIUM, "include/cronhooks.php");
  536. // Cleaning dead processes
  537. poller_kill_stale_workers();
  538. }
  539. if (array_search(__file__,get_included_files())===0){
  540. poller_run($_SERVER["argv"],$_SERVER["argc"]);
  541. get_app()->end_process();
  542. killme();
  543. }