TFS 0.X Restart the server on LUA

newby

Active Member
Joined
Jun 11, 2016
Messages
183
Reaction score
43
Is it possible to restart the server only with LUA script?

I did this script to save players, clean the map and this stuff

<globalevent name="full ss" time="03:47" event="script" value="fullserversave.lua"/>
Code:
function onTime()
    doBroadcastMessage('Server is going down for a global save within 5 minutes. Please logout.')
    addEvent(CloseServer, 5 * 60 * 1000)
    return true
end
function CloseServer()
    local state = GAMESTATE_CLOSED
    doSetGameState(state)
    addEvent(ServerSave, 3 * 60 * 1000)
    return true
end
function ServerSave()
    doSaveServer()
    addEvent(ServerClean, 3 * 60 * 1000, cid, experience)
    return true
end
function ServerClean()
    doCleanMap()
    addEvent(OpenServer, 3 * 60 * 1000)
    return true
end
function OpenServer()
    local state = GAMESTATE_NORMAL
    doSetGameState(state)
    return true
end


But i would like to shutdown the server and re-open to apply new updates
Is it possible?
 

slaw

Developer
Joined
Aug 27, 2007
Messages
3,255
Solutions
95
Reaction score
739
Location
Germany
GitHub
slawkens
You can use restarter like this: Auto Restart Linux (https://otland.net/threads/auto-restart-linux.262336/)

So when your server goes down after global save, it will be auto started.

The second option is to create a cronjob (scheduled task), that will automatically open at x. o'clock.

Script: (auto_start.sh) - place in same folder where tfs
Code:
#!/bin/bash
ulimit -c unlimited
screen -dmS tfs ./tfs

Then, you need to edit crontab with command:
Code:
crontab -e

and paste there
Code:
0 4 * * * /home/forgottenserver/auto_start.sh >/dev/null 2>&1

This will open server at 4:00
 
OP
newby

newby

Active Member
Joined
Jun 11, 2016
Messages
183
Reaction score
43
You can use restarter like this: Auto Restart Linux (https://otland.net/threads/auto-restart-linux.262336/)

So when your server goes down after global save, it will be auto started.

The second option is to create a cronjob (scheduled task), that will automatically open at x. o'clock.

Script: (auto_start.sh) - place in same folder where tfs
Code:
#!/bin/bash
ulimit -c unlimited
screen -dmS tfs ./tfs

Then, you need to edit crontab with command:
Code:
crontab -e

and paste there
Code:
0 4 * * * /home/forgottenserver/auto_start.sh >/dev/null 2>&1

This will open server at 4:00

Wich do you recommend?
The first one looks like it will always restart the server, every crash or something i'll not see, it will restart automatically
The second one looks like if the server still open on 04:00 it will try again...
If i put:
Code:
    globalSaveEnabled = true
    globalSaveHour = 5
    globalSaveMinute = 0
    shutdownAtGlobalSave = true
    cleanMapAtGlobalSave = true

Code:
5 4 * * * /home/forgottenserver/auto_start.sh >/dev/null 2>&1
Is a safe time? It is 04:05?
I scare to do some shit and also scare to lose uptime on otservlist

How would u do this?
 
OP
newby

newby

Active Member
Joined
Jun 11, 2016
Messages
183
Reaction score
43
Yes its 4:05.

Personally I would use the first option - restarter, if you care about otservlist uptime.

Can u think about any other why to use the second one?

I mean, if someone is crashing my server they will have a free clone...
But anyways, server shouldn't crash xD
And it is better to someone be cloning then the server be offline

My point is u choose the first one because of uptime on otservlist or because u think it is better at all?
 
Top