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