Jump to content

[Question/Request] Automatic Server Restart Function


c3pu

Recommended Posts

How would I implement the new save() and stop() functions to make a server restart script? I have tried running something like:

 

now = os.time()
then = now + 3600
while
if (os.time >= then) then
save()
Server():broadcastChatMessage("Server", 0, "--Restarting Server--")
stop()
end
end

 

Help would be greatly appreciated :)

 

Link to comment
Share on other sites

How would I implement the new save() and stop() functions to make a server restart script? I have tried running something like:

 

now = os.time()

then = now + 3600

while

if (os.time >= then) then

save()

Server():broadcastChatMessage("Server", 0, "--Restarting Server--")

stop()

end

end

 

Help would be greatly appreciated :)

 

Linux or Windows ?

Link to comment
Share on other sites

First issue I see is:

then = now + 3600

 

You can't use then as identifier.

 

You could use os.execute([command]) to use external commands as far as I tested - it works.

 

But putting server restarting script into the server itself is a bad design. There are tools that allows you to schedule tasks on most OSes. Using external scripts to manage server is easier to use and to configure, is more secure and more fault proof.

Link to comment
Share on other sites

First issue I see is:

then = now + 3600

 

You can't use then as identifier.

 

You could use os.execute([command]) to use external commands as far as I tested - it works.

 

But putting server restarting script into the server itself is a bad design. There are tools that allows you to schedule tasks on most OSes. Using external scripts to manage server is easier to use and to configure, is more secure and more fault proof.

 

Ok thanks, this was just pseudo code, I have never actually coded in LUA. I'll try doing something when the Server Launcher works later on.

Link to comment
Share on other sites

Has anyone made a fully functional script to say reboot the server using /stop every say 3-6 hours with an announcement maybe 15 10 5 and then 4 3 2 1 and then 30 seconds and down countdown?

 

Not much of a scripter myself so hoping someone has something for this.

Link to comment
Share on other sites

As far as I remember you use nix, so:

http://www.avorion.net/forum/index.php/topic,642.0.html

with cron:

 

0   0,6,12,18 * * * avorion <path>/manager restart
55 23,5,11,17 * * * avorion <path>/manager warning 5
50 23,5,11,17 * * * avorion <path>/manager warning 10
45 23,5,11,17 * * * avorion <path>/manager warning 15

 

Or similar. You could also probably adjust your own script for that.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...