SA-MP Forums Archive
auto restart after crash - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: auto restart after crash (/showthread.php?tid=218178)



auto restart after crash - Baboon - 29.01.2011

If the server is crashed, can it be auto restarted?
Please tell me, because I just had 27 players in my server (new record) and it crashed.


Re: auto restart after crash - JaTochNietDan - 29.01.2011

Well assuming you're on Windows, then you need some sort of code to monitor the server process. I still have a batch file made by yom ages ago, here's the source code. Just open a text file and save as a .bat, then put it in your server directory and run it.

Code:
@ECHO OFF
TITLE Yom's SA-MP server restarter
COLOR 09

SET option_log=0

SET folder=restarter
SET file_1=server_log.txt
SET file_2=%folder%\server.log
SET file_3=%folder%\restarter.log
SET file_4=%folder%\reset.reg
SET server=samp-server.exe
SET count=0
SET regkey="HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug"



IF NOT EXIST %server% (

	COLOR 0C
	ECHO %server% was not found!
	ECHO Press any key to exit.
	PAUSE > NUL
	GOTO EOF
)



IF NOT EXIST %folder% MD %folder%



IF NOT EXIST %file_4% (

	REG EXPORT %regkey% %file_4% > NUL
	REG ADD %regkey% /V Auto /D 1 /F > NUL
	REG ADD %regkey% /V Debugger /D 0 /F > NUL
)



:START

	CLS & ECHO.

	SET hh=%time:~0,2%

	IF %hh% LSS 10 SET hh=0%time:~1,1%

	SET msg=[%date%][%hh%:%time:~3,5%] Server

	IF %count% EQU 0 (SET msg=%msg% started.) ELSE SET msg=%msg% restarted [%count%x].

	ECHO  %msg% & ECHO %msg%>> %file_3%

	IF %option_log% EQU 1 (

		ECHO %msg%>> %file_2%
		TYPE %file_1%>> %file_2%
		FOR /L %%i IN (1,1,4) DO ECHO.>> %file_2%
	)

	GOTO NEXT



:NEXT

	SET /A count+=1
	CALL %server%
	GOTO START



:EOF



Re: auto restart after crash - Baboon - 29.01.2011

omg thanks you.
but where should I set my folder?


Re: auto restart after crash - JaTochNietDan - 29.01.2011

Quote:
Originally Posted by timothyinthehouse
View Post
omg thanks you.
but where should I set my folder?
That variable just defines where the restarter logs are stored, set it to whatever name you want.


Re: auto restart after crash - Baboon - 29.01.2011

ive did this:

SET folder=C:\Users\Timothy\Desktop\0.3c rc8

but it is not working?


Re: auto restart after crash - JaTochNietDan - 29.01.2011

Did you place the .bat file in the same directory as the samp-server.exe like I said? Also you do not need to put the entire path to your SA-MP server in the folder variable, it just needs the subdirectory where you want to save the restarter logs.


Re: auto restart after crash - Baboon - 29.01.2011

aha ok, thnx


Re: auto restart after crash - [FAT]Klabauter[LST] - 20.11.2011

Is there a way to do this on linux?


Re: auto restart after crash - ColorHost-Kevin - 20.11.2011

Quote:
Originally Posted by [FAT]Klabauter[LST]
View Post
Is there a way to do this on linux?
We see your a client with us.

Your server is crashing due to the DDOS attack that is going on with one of our other clients, were taking action towards him and restoring this server at this time.

Please check your email for details in regards to this.

Thanks.


Re: auto restart after crash - Chris White - 20.11.2011

Follow this thread: https://sampwiki.blast.hk/wiki/Linux_Ser..._Server_Online