|
Last change
on this file was 404, checked in by george, 17 years ago |
- Upraveno: Názvy databází MaNGOSu přesunuty do konfiguračního souboru a odkazované skripty upraveny k použití těchto proměnných.
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | <?php
|
|---|
| 2 | $MangosUptimeInterval = 60; // Matches UpdateUptimeInterval in mangosd.conf [seconds]
|
|---|
| 3 | $RestartDeadTime = 3 * 60; // Maximum dead time [seconds]
|
|---|
| 4 | $LoopSleepTime = 10; // Checking period [seconds]
|
|---|
| 5 | $MangosProcessName = '/a/mangos1/bin/mangos-worldd';
|
|---|
| 6 |
|
|---|
| 7 | include('../global.php');
|
|---|
| 8 |
|
|---|
| 9 | echo('MaNGOS freeze restarter. Checking DB every '.$LoopSleepTime." seconds\n");
|
|---|
| 10 | $Restarted = 0;
|
|---|
| 11 | $Database->select_db('realm1_mangos');
|
|---|
| 12 | while(1)
|
|---|
| 13 | {
|
|---|
| 14 | $DbResult = $Database->query('SELECT `starttime`, `uptime` FROM `uptime` ORDER BY `starttime` DESC LIMIT 1');
|
|---|
| 15 | $DbRow = $DbResult->fetch_array();
|
|---|
| 16 | $DbUptime = $DbRow['uptime'];
|
|---|
| 17 | $RealUptime = time() - $DbRow['starttime'];
|
|---|
| 18 | $TimeDifference = $RealUptime - $DbUptime;
|
|---|
| 19 | echo('Uptime DB: '.$DbUptime.' vs. Real: '.$RealUptime." [s], Restart condition ".$TimeDifference." > ".$RestartDeadTime.
|
|---|
| 20 | " (".round($TimeDifference / $RestartDeadTime * 100)."%)\n");
|
|---|
| 21 | if($TimeDifference > $RestartDeadTime)
|
|---|
| 22 | {
|
|---|
| 23 | if($Restarted == 0)
|
|---|
| 24 | {
|
|---|
| 25 | echo("Restarting MaNGOS...\n");
|
|---|
| 26 | exec("ps -ef | grep '".$MangosProcessName."' | grep -v grep | awk '{print $2}' | xargs -i kill {}");
|
|---|
| 27 | $Restarted = 1; // Restart only once and wait for new good uptime
|
|---|
| 28 | echo("Waiting for new good uptime...\n");
|
|---|
| 29 | }
|
|---|
| 30 | } else
|
|---|
| 31 | {
|
|---|
| 32 | if($Restarted == 1)
|
|---|
| 33 | {
|
|---|
| 34 | echo("MaNGOS is back online.\n");
|
|---|
| 35 | $Restarted = 0;
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
| 38 | Sleep($LoopSleepTime);
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | ?>
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.