버그 수정, 반복 도구 강화
This commit is contained in:
@@ -100,6 +100,11 @@ class ResetHelper{
|
|||||||
], true
|
], true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
copy(
|
||||||
|
$servRoot.'/d_setting/GameConst.orig.php',
|
||||||
|
$servRoot.'/d_setting/GameConst.php',
|
||||||
|
);
|
||||||
|
|
||||||
if($mysqli_obj->multi_query(file_get_contents($servRoot.'/sql/reset.sql'))){
|
if($mysqli_obj->multi_query(file_get_contents($servRoot.'/sql/reset.sql'))){
|
||||||
while(true){
|
while(true){
|
||||||
if (!$mysqli_obj->more_results()) {
|
if (!$mysqli_obj->more_results()) {
|
||||||
|
|||||||
+1
-2
@@ -299,8 +299,7 @@ CREATE TABLE IF NOT EXISTS `ng_games` (
|
|||||||
`season` INT(11) NOT NULL,
|
`season` INT(11) NOT NULL,
|
||||||
`scenario` INT(11) NOT NULL,
|
`scenario` INT(11) NOT NULL,
|
||||||
`scenario_name` TEXT NOT NULL,
|
`scenario_name` TEXT NOT NULL,
|
||||||
`env` TEXT NOT NULL CHECK (json_valid(`aux`)),
|
`env` TEXT NOT NULL CHECK (json_valid(`env`)),
|
||||||
CHECK (JSON_VALID(`env`)),
|
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE INDEX `server_id` (`server_id`),
|
UNIQUE INDEX `server_id` (`server_id`),
|
||||||
INDEX `date` (`date`)
|
INDEX `date` (`date`)
|
||||||
|
|||||||
+43
-18
@@ -7,11 +7,28 @@ import urllib.request
|
|||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
ONE_FILE_LOOP_SEC = 60
|
||||||
|
ONE_LOOP_TIME_SEC = 6
|
||||||
|
RETRY_SEC = 2
|
||||||
|
|
||||||
|
def getCurrentMillisecTime():
|
||||||
|
return int(time.time() * 1000)
|
||||||
|
|
||||||
|
|
||||||
def run(webPath):
|
def run(webPath):
|
||||||
now = datetime.now()
|
for _ in range(5):
|
||||||
print(now.strftime("%Y-%m-%d %H:%M:%S"), webPath)
|
now = datetime.now()
|
||||||
obj = urllib.request.urlopen(webPath)
|
print(now.strftime("%Y-%m-%d %H:%M:%S"), webPath)
|
||||||
obj.read()
|
startTime = getCurrentMillisecTime()
|
||||||
|
|
||||||
|
obj = urllib.request.urlopen(webPath)
|
||||||
|
obj.read()
|
||||||
|
|
||||||
|
timeGap = getCurrentMillisecTime() - startTime
|
||||||
|
if timeGap < RETRY_SEC * 1000:
|
||||||
|
break
|
||||||
|
print(webPath, timeGap, 'retry')
|
||||||
|
return getCurrentMillisecTime()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
basepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
basepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
@@ -37,29 +54,37 @@ def main():
|
|||||||
resetAbsPath = servPath + '/j_autoreset.php'
|
resetAbsPath = servPath + '/j_autoreset.php'
|
||||||
resetPath = webBase + '/' + servRelPath + '/j_autoreset.php'
|
resetPath = webBase + '/' + servRelPath + '/j_autoreset.php'
|
||||||
if os.path.exists(resetAbsPath):
|
if os.path.exists(resetAbsPath):
|
||||||
autoResetList.append(resetPath)
|
autoResetList.append((servRelPath, resetPath))
|
||||||
|
|
||||||
if servPath in hiddenList:
|
if servPath in hiddenList:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
webPath = webBase + '/' + servRelPath + '/proc.php'
|
webPath = webBase + '/' + servRelPath + '/proc.php'
|
||||||
|
|
||||||
servList.append(webPath)
|
servList.append((servRelPath,webPath))
|
||||||
|
|
||||||
with concurrent.futures.ThreadPoolExecutor(max_workers=max(1,len(servList))) as executor:
|
with concurrent.futures.ThreadPoolExecutor(max_workers=max(1,len(servList))) as executor:
|
||||||
waiters=[]
|
waiters={}
|
||||||
for resetPath in autoResetList:
|
startTime = getCurrentMillisecTime()
|
||||||
|
|
||||||
|
waitTick = 1.0 / max(len(autoResetList), 1)
|
||||||
|
for servRelPath, resetPath in autoResetList:
|
||||||
future = executor.submit(run, resetPath)
|
future = executor.submit(run, resetPath)
|
||||||
waiters.append(future)
|
waiters[servRelPath] = future
|
||||||
for idx in range(10):
|
time.sleep(waitTick)
|
||||||
for webPath in servList:
|
|
||||||
future = executor.submit(run, webPath)
|
currTime = getCurrentMillisecTime()
|
||||||
waiters.append(future)
|
|
||||||
if idx == 9:
|
waitTick = ONE_LOOP_TIME_SEC / max(len(servList), 1)
|
||||||
break
|
while currTime - startTime < ONE_FILE_LOOP_SEC*1000:
|
||||||
time.sleep(6)
|
for servRelPath, webPath in servList:
|
||||||
for future in waiters:
|
if servRelPath in waiters and not waiters[servRelPath].done():
|
||||||
future.done()
|
continue
|
||||||
|
waiters[servRelPath] = executor.submit(run, webPath)
|
||||||
|
time.sleep(waitTick)
|
||||||
|
|
||||||
|
for future in waiters.values():
|
||||||
|
future.result(None)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# execute only if run as a script
|
# execute only if run as a script
|
||||||
|
|||||||
Reference in New Issue
Block a user