$runNow) { $sql="select tablename from pg_tables where schemaname = 'public' and tablename = 'lock_".$channelInfoNew[$channelInfoKey]["chanid"]."';"; $result=pg_query($globalsettings["db"]["pg_conn"], $sql); if (pg_num_rows($result) !=0 ) { /* logger("job: backgroundworker - lock table exists, job not running(broken job): drop table lock_".$channelInfoNew[$channelInfoKey]["chanid"]); dropTable("lock_".$channelInfoNew[$channelInfoKey]["chanid"]); */ $sql="select max(msgid) as maxid from lock_".$channelInfoNew[$channelInfoKey]["chanid"].";"; $result=pg_query($globalsettings["db"]["pg_conn"], $sql); if (pg_num_rows($result) !=0) { while ($row = pg_fetch_array($result)) { $maxid=$row["maxid"]; } // if ($numrows != 0) } // while ($row = pg_fetch_array logger("job: channelReader - lock table[".$channelInfoNew[$channelInfoKey]["name"]."] exists, start job at message ".$maxid); $top_message=made("messages","getPeerDialogs", array("peers" => array($channelInfoNew[$channelInfoKey]["peerid"])))["dialogs"][0]["top_message"]; logger("job: chnStepper - setup stepper for [".$channelInfoNew[$channelInfoKey]["name"]."] from ".$maxid." to ".$top_message); $bckStepArray[$channelInfoNew[$channelInfoKey]["peerid"]]["limit"]=100; $bckStepArray[$channelInfoNew[$channelInfoKey]["peerid"]]["from"] =$maxid; $bckStepArray[$channelInfoNew[$channelInfoKey]["peerid"]]["to"] =$top_message; $bckStepArray[$channelInfoNew[$channelInfoKey]["peerid"]]["maxid"]=$top_message; // obsolet during top_message... } // if (pg_num_rows($result) !=0 ) pg_query($globalsettings["db"]["pg_conn"], pg_channelTableTemplate("chan_".$channelInfoNew[$channelInfoKey]["chanid"])); // create chan table when not exists pg_query($globalsettings["db"]["pg_conn"], pg_channelTableTemplate("lock_".$channelInfoNew[$channelInfoKey]["chanid"])); // create lock table when not exists $isJobRunning["backgroundWorker"]["isrunning"]=1; $isJobRunning["backgroundWorker"]["chanid"]=$channelInfoNew[$channelInfoKey]["chanid"]; $isJobRunning["backgroundWorker"]["name"]=$channelInfoNew[$channelInfoKey]["name"]; $isJobRunning["backgroundWorker"]["starttime"]=time(); $isJobRunning["backgroundWorker"]["channelInfoKey"]=$channelInfoKey; logger("job: channelReader - start on [".$channelInfoNew[$channelInfoKey]["name"]."]"); break; } // if (time() > $runNow) } // if ($channelInfoNew[$channelInfoKey]["status"] == "ok" && $channelInfoNew[$channelInfoKey]["mode"] != "a") } // foreach(array_keys($channelInfoNew) as $k) } else { $channelInfoKey=$isJobRunning["backgroundWorker"]["channelInfoKey"]; $stepsleft=round(($bckStepArray[$channelInfoNew[$channelInfoKey]["peerid"]]["to"] - $bckStepArray[$channelInfoNew[$channelInfoKey]["peerid"]]["from"]) / $bckStepArray[$channelInfoNew[$channelInfoKey]["peerid"]]['limit']); logger("job: channelReader - work on [".$channelInfoNew[$channelInfoKey]["name"]."], current msg: ".$bckStepArray[$channelInfoNew[$channelInfoKey]["peerid"]]["from"]." to goal: ".$bckStepArray[$channelInfoNew[$channelInfoKey]["peerid"]]["to"]); } // if ($isJobRunning["backgroundWorker"]["isrunning"] == -1) - else return; } // function end