Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Commit f7c6439

Browse files
committed
Fixed conflict in Control
1 parent dd9de6e commit f7c6439

File tree

1 file changed

+0
-89
lines changed

1 file changed

+0
-89
lines changed

src/models/Control.php

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -335,95 +335,6 @@ class Control extends Model {
335335
}
336336
}
337337

338-
public static async function genAutoBegin(): Awaitable<void> {
339-
// Get start time
340-
$config_start_ts = await Configuration::gen('start_ts');
341-
$start_ts = intval($config_start_ts->getValue());
342-
343-
// Get end time
344-
$config_end_ts = await Configuration::gen('end_ts');
345-
$end_ts = intval($config_end_ts->getValue());
346-
347-
// Get paused status
348-
$config_game_paused = await Configuration::gen('game_paused');
349-
$game_paused = intval($config_game_paused->getValue());
350-
351-
if (($game_paused === 0) && ($start_ts <= time()) && ($end_ts > time())) {
352-
// Start the game
353-
await Control::genBegin();
354-
}
355-
}
356-
357-
public static async function genAutoEnd(): Awaitable<void> {
358-
// Get start time
359-
$config_start_ts = await Configuration::gen('start_ts');
360-
$start_ts = intval($config_start_ts->getValue());
361-
362-
// Get end time
363-
$config_end_ts = await Configuration::gen('end_ts');
364-
$end_ts = intval($config_end_ts->getValue());
365-
366-
// Get paused status
367-
$config_game_paused = await Configuration::gen('game_paused');
368-
$game_paused = intval($config_game_paused->getValue());
369-
370-
if (($game_paused === 0) && ($end_ts <= time())) {
371-
// Start the game
372-
await Control::genEnd();
373-
}
374-
}
375-
376-
public static async function genAutoRun(): Awaitable<void> {
377-
// Get start time
378-
$config_game = await Configuration::gen('game');
379-
$game = intval($config_game->getValue());
380-
381-
if ($game === 0) {
382-
// Check and start the game
383-
await Control::genAutoBegin();
384-
} else {
385-
// Check and stop the game
386-
await Control::genAutoEnd();
387-
}
388-
}
389-
390-
public static async function genRunAutoRunScript(): Awaitable<void> {
391-
$autorun_status = await Control::checkScriptRunning('autorun');
392-
if ($autorun_status === false) {
393-
$autorun_location = escapeshellarg(
394-
must_have_string(Utils::getSERVER(), 'DOCUMENT_ROOT').
395-
'/scripts/autorun.php',
396-
);
397-
$cmd =
398-
'hhvm -vRepo.Central.Path=/var/run/hhvm/.hhvm.hhbc_autorun '.
399-
$autorun_location.
400-
' > /dev/null 2>&1 & echo $!';
401-
$pid = shell_exec($cmd);
402-
await Control::genStartScriptLog(intval($pid), 'autorun', $cmd);
403-
}
404-
}
405-
406-
public static async function checkScriptRunning(
407-
string $name,
408-
): Awaitable<bool> {
409-
$db = await self::genDb();
410-
$result = await $db->queryf(
411-
'SELECT pid FROM scripts WHERE name = %s AND status = 1 LIMIT 1',
412-
$name,
413-
);
414-
if ($result->numRows() >= 1) {
415-
$pid = intval(must_have_idx($result->mapRows()[0], 'pid'));
416-
$status = file_exists("/proc/$pid");
417-
if ($status === false) {
418-
await Control::genStopScriptLog($pid);
419-
await Control::genClearScriptLog();
420-
}
421-
return $status;
422-
} else {
423-
return false;
424-
}
425-
}
426-
427338
public static async function importGame(): Awaitable<bool> {
428339
$data_game = JSONImporterController::readJSON('game_file');
429340
if (is_array($data_game)) {

0 commit comments

Comments
 (0)