summaryrefslogtreecommitdiff
path: root/serv.bat
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-22 12:36:39 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-22 12:36:39 +0000
commita21bc85c2316d2ecbb1d1b2f6bdcc055928faf60 (patch)
tree25869eebefe23b0e339bf41d00e41d8481691c65 /serv.bat
parent7dc7a1fc2071ca796ca1cbb091a6b97d412a41f1 (diff)
downloadhercules-a21bc85c2316d2ecbb1d1b2f6bdcc055928faf60.tar.gz
hercules-a21bc85c2316d2ecbb1d1b2f6bdcc055928faf60.tar.bz2
hercules-a21bc85c2316d2ecbb1d1b2f6bdcc055928faf60.tar.xz
hercules-a21bc85c2316d2ecbb1d1b2f6bdcc055928faf60.zip
* Batch files (Windows) now detect whether the server crashed, aborted or shutdown cleanly (Ctrl+C or @mapexit) and print appropriate message, instead of always assuming, that the server crashed (bugreport:3476, since r1818).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14484 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'serv.bat')
-rwxr-xr-xserv.bat59
1 files changed, 59 insertions, 0 deletions
diff --git a/serv.bat b/serv.bat
new file mode 100755
index 000000000..6e8037faa
--- /dev/null
+++ b/serv.bat
@@ -0,0 +1,59 @@
+@ECHO OFF
+IF "%1"=="" GOTO DIRECT
+IF "%2"=="" GOTO DIRECT
+IF NOT EXIST "%1" GOTO NOTFOUND
+GOTO START
+
+REM == How RESTART_9X and RESTART_NT works =========================
+REM On Windows 9x only the first 8 characters are significant for
+REM labels, and the first matching one is called (RESTART_(9X)).
+REM Windows NT calls the exact named label (RESTART_NT).
+REM Separation between 9X and NT is required, because CHOICE has
+REM different syntax on these platforms or does not exist as all.
+REM ================================================================
+
+REM Windows 95, 98, ME
+:RESTART_9X
+REM Old Ctrl+C in PING does not work, because that only stops ping,
+REM not the batch file.
+CHOICE /C:rc /N /T:R,15 Restarting in 15 seconds, press 'C' to cancel.
+IF NOT ERRORLEVEL 2 GOTO START
+GOTO END
+
+REM Windows 2000, XP, Vista, 7
+:RESTART_NT
+REM There is no CHOICE in 2000 and XP, but you get asked whether to
+REM abort the batch file, when pressing Ctrl+C in PING.
+ECHO Restarting in 15 seconds, press Ctrl+C to cancel.
+PING -n 15 127.0.0.1 > NUL
+
+:START
+%1
+ECHO.
+REM Return value > 1 is exception&~0xC0000000
+IF ERRORLEVEL 2 GOTO CRASHED
+REM Return value 1 is EXIT_FAILURE
+IF ERRORLEVEL 1 GOTO EXIT1
+REM Return value 0 is EXIT_SUCCESS
+ECHO %2 has shutdown successfully.
+GOTO RESTART_NT
+
+:EXIT1
+ECHO %2 has terminated abnormally.
+GOTO RESTART_NT
+
+:CRASHED
+ECHO %2 has crashed!
+GOTO RESTART_NT
+
+:DIRECT
+ECHO Do not run this file directly. It is used by logserv.bat, charserv.bat,
+ECHO mapserv.bat and their '-sql' counterparts.
+GOTO END
+
+:NOTFOUND
+ECHO %1 was not found. Make sure, that you have compiled the %2.
+GOTO END
+
+:END
+PAUSE