-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathRenewal.bat
132 lines (107 loc) · 3.3 KB
/
Renewal.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
@echo off
rem This is and auto-restart script for the rAthena Ragnarok Online Server Emulator.
rem It will also keep the map server OPEN after it crashes to that errors may be
rem more easily identified
rem Writen by Jbain
rem modified by lighta
set SOURCE_DIR=%~dp0
cd %SOURCE_DIR%
if ["%~1"]==[""] (
REM this is for backward compatibility
set "target=watch"
) else set target=%~1
echo "target=%target%"
REM to avoid any localization issue
set "login_running=false"
set "char_running=false"
set "map_running=false"
if "%target%" == "status" (
call :getStatus
) else if "%target%" == "watch" (
call :Watch
) else if "%target%" == "stop" (
call :Stop
) else if "%target%" == "stop" (
call :Stop
) else if "%target%" == "start" (
call :Start
)
goto :EOF
:Stop
echo "Stoping all serv"
call :stopLogin
call :stopChar
call :stopMap
goto :EOF
:Watch
REM this is to align terminology with athena-start, (start with restart mode)
echo "Starting all serv"
set "restart_mode=on"
call :startLogin
call :startChar
call :startMap
goto :EOF
:Start
echo "Starting all serv"
set "restart_mode=off"
call :startLogin
call :startChar
call :startMap
goto :EOF
:getStatus
echo "Getting status of all serv"
call :getLoginStatus
call :getCharStatus
call :getMapStatus
if "%login_running%" == "false" ( echo "login_serv is not running"
) else echo "login_serv is running pid=%LoginServPID%"
if "%char_running%" == "false" ( echo "char_serv is not running"
) else echo "char_serv is running pid=%CharServPID%"
if "%map_running%" == "false" ( echo "map_serv is not running"
) else echo "map_serv is running pid=%MapServPID%"
goto :EOF
REM ====
REM sub targets (a target per serv)
REM ====
REM stop sub targets
:stopLogin
call :getLoginStatus
if "%login_running%" == "true" Taskkill /PID %LoginServPID% /F
goto :EOF
:stopChar
call :getCharStatus
if "%char_running%" == "true" Taskkill /PID %CharServPID% /F
goto :EOF
:stopMap
call :getMapStatus
if "%map_running%" == "true" Taskkill /PID %MapServPID% /F
goto :EOF
REM start sub targets
:startLogin
call :getLoginStatus
if "%login_running%" == "false" ( start cmd /k tools\batches\logserv.bat %restart_mode%
) else echo "Login serv is already running pid=%LoginServPID%"
goto :EOF
:startChar
call :getCharStatus
if "%char_running%" == "false" ( start cmd /k tools\batches\charserv.bat %restart_mode%
) else echo "Char serv is already running, pid=%CharServPID%"
goto :EOF
:startMap
call :getMapStatus
if "%map_running%" == "false" ( start cmd /k tools\batches\mapserv.bat %restart_mode%
) else echo "Map serv is already running, pid=%MapServPID%"
goto :EOF
REM status sub targets
:getLoginStatus
for /F "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq login-server.exe"') do set LoginServPID=%%b
echo(%LoginServPID%|findstr "^[-][1-9][0-9]*$ ^[1-9][0-9]*$ ^0$">nul&& set "login_running=true" || set "login_running=false"
goto :EOF
:getCharStatus
for /F "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq char-server.exe"') do set CharServPID=%%b
echo(%CharServPID%|findstr "^[-][1-9][0-9]*$ ^[1-9][0-9]*$ ^0$">nul&& set "char_running=true" || set "char_running=false"
goto :EOF
:getMapStatus
for /F "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq map-server.exe"') do set MapServPID=%%b
echo(%MapServPID%|findstr "^[-][1-9][0-9]*$ ^[1-9][0-9]*$ ^0$">nul&& set "map_running=true" || set "map_running=false"
goto :EOF