From 1f730f59e7e940ae4d016e3774436531980aee5e Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Wed, 19 Feb 2020 15:59:22 +0900 Subject: [PATCH] Update index.php --- index.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.php b/index.php index 72e3186..0219424 100644 --- a/index.php +++ b/index.php @@ -91,6 +91,16 @@ $requests = get_requests(); // get PID(Process ID) set_shared_var("mypid", getmypid()); +// set limit of CPU usage +$min_cpu_idle = floatval(get_value_in_array("min_cpu_idle", $config, 0)); // range: 0.0(0%) ~ 1.0(100%) +$cpu_sleep_time = floatval(get_value_in_array("cpu_sleep_time", $config, 3)); // default: 3 seconds +if($min_cpu_idle > 0 && $min_cpu_idle < 1 && loadHelper("perftool")) { + while(get_cpu_idle() < $min_cpu_idle) { + sleep($cpu_sleep_time); + write_common_log(sprintf("CPU usage exceeded, wait a %s second(s)...", $cpu_sleep_time), "index"); + } +} + // set database connection // variable _unset_dbc: will not connect to database $_unset_dbc = get_requested_value("_unset_dbc");