X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/0a2b3443b20d5f3d8ec855755dda71ed9ca799b8..67bff06aa6fd4d7d3a9aefc2919307326fa6d755:/api/common_api.php diff --git a/api/common_api.php b/api/common_api.php index d94ef68..ccb1442 100644 --- a/api/common_api.php +++ b/api/common_api.php @@ -1,5 +1,5 @@ log()->subscribe($sources); if ($rpc->error) @@ -61,7 +89,10 @@ function api_log_loop($sources) * otherwise PHP may not * notice when the webclient is gone. */ - echo "\n"; + if ($fpm_workaround_needed) + echo str_repeat(" ", 4095)."\n"; + else + echo "\n"; continue; } send_sse($res); @@ -72,6 +103,11 @@ function api_timer_loop(int $every_msec, string $method, array|null $params = nu { GLOBAL $rpc; + /* First, execute it immediately */ + $res = $rpc->query($method, $params); + if (!$res) + die; + send_sse($res); $rpc->rpc()->add_timer("timer", $every_msec, $method, $params); if ($rpc->error) { @@ -82,10 +118,17 @@ function api_timer_loop(int $every_msec, string $method, array|null $params = nu if (!$res) die; send_sse($res); + usleep($every_msec * 1000); } } /* New style: use server-side timers */ + /* - First, execute it immediately */ + $res = $rpc->query($method, $params); + if (!$res) + die; + send_sse($res); + /* - Then add the timer */ for(;;) { $res = $rpc->eventloop(); @@ -95,7 +138,10 @@ function api_timer_loop(int $every_msec, string $method, array|null $params = nu * otherwise PHP may not * notice when the webclient is gone. */ - echo "\n"; + if ($fpm_workaround_needed) + echo str_repeat(" ", 4095)."\n"; + else + echo "\n"; continue; } send_sse($res);