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