Automatic Server Restart Script
Automatic Server Restart Script
does anyone have a script to automatically restart servers if they crash.
Coding;
1X coding
3X debugging
12X tweaking to be just right
1X coding
3X debugging
12X tweaking to be just right
- VanessaE
- Moderator
- Posts: 4655
- Joined: Sun Apr 01, 2012 12:38
- GitHub: VanessaE
- IRC: VanessaE
- In-game: VanessaE
- Location: Western NC
- Contact:
I use this (with stuff specific to my needs filled-in, of course):
Pretty simple stuff. It just loops, always waiting one second before restarting after a crash. Nothing fancy.
Note that something this simple can't protect against a server just locking up and consuming CPU - it'll only protect against the server crashing and exiting. For that, you'll need to write a script that scrapes the output from top or ps or something and measures how long the server stays in that state, then deliberately kills and restarts it if it exceeds some reasonable threshold.
Code: Select all
#!/bin/bash
while true
do
sleep 1
minetestserver --config /path/to/your/minetest.conf \
--worldname name_of_your_world_here \
--gameid your_game_here \
--port 30000 \
--logfile /path/to/servers/debug.txt
done
Note that something this simple can't protect against a server just locking up and consuming CPU - it'll only protect against the server crashing and exiting. For that, you'll need to write a script that scrapes the output from top or ps or something and measures how long the server stays in that state, then deliberately kills and restarts it if it exceeds some reasonable threshold.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)
I am new to Minetest and am working with 12Me21 to create our own server and I have a few questions about this cron job.
-how do I determine my worldname and gameid?
-where do i store this cron job? cron.d?
Thanks!
-how do I determine my worldname and gameid?
-where do i store this cron job? cron.d?
Thanks!
VanessaE wrote:I use this (with stuff specific to my needs filled-in, of course):
Pretty simple stuff. It just loops, always waiting one second before restarting after a crash. Nothing fancy.Code: Select all
#!/bin/bash while true do sleep 1 minetestserver --config /path/to/your/minetest.conf \ --worldname name_of_your_world_here \ --gameid your_game_here \ --port 30000 \ --logfile /path/to/servers/debug.txt done
Note that something this simple can't protect against a server just locking up and consuming CPU - it'll only protect against the server crashing and exiting. For that, you'll need to write a script that scrapes the output from top or ps or something and measures how long the server stays in that state, then deliberately kills and restarts it if it exceeds some reasonable threshold.
VanessaE ,
Can you help me with this script? I have my worldname and gamed I just don't know where to put the script.
Thanks
Can you help me with this script? I have my worldname and gamed I just don't know where to put the script.
Thanks
VanessaE wrote:I use this (with stuff specific to my needs filled-in, of course):
Pretty simple stuff. It just loops, always waiting one second before restarting after a crash. Nothing fancy.Code: Select all
#!/bin/bash while true do sleep 1 minetestserver --config /path/to/your/minetest.conf \ --worldname name_of_your_world_here \ --gameid your_game_here \ --port 30000 \ --logfile /path/to/servers/debug.txt done
Note that something this simple can't protect against a server just locking up and consuming CPU - it'll only protect against the server crashing and exiting. For that, you'll need to write a script that scrapes the output from top or ps or something and measures how long the server stays in that state, then deliberately kills and restarts it if it exceeds some reasonable threshold.
- VanessaE
- Moderator
- Posts: 4655
- Joined: Sun Apr 01, 2012 12:38
- GitHub: VanessaE
- IRC: VanessaE
- In-game: VanessaE
- Location: Western NC
- Contact:
You can place the script anywhere you want, the point is to run it. I keep it in the home directory for the user that the server runs as, and it is run from /etc/rc.local at system boot (via su and screen, so that it runs as the proper userid).
On my regular user account, I keep all my various scripts in ~/Scripts.
On my regular user account, I keep all my various scripts in ~/Scripts.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)
I get the following error:
Terminate called after throwing and instance of 'std::logic_error'
what (): basic_strig::_S_construct null not valid
/home/12Me22/scripts/restartminetest.sh: line 8: 1056 Aborted
#!/bin/bash
while true
do
sleep 1
minetestserver --config /home/12Me22/minetest/minetest.conf --world /home/12Me22/minetest/worlds/world \
--logfile /home/12Me22/backups/debug.txt
done
Terminate called after throwing and instance of 'std::logic_error'
what (): basic_strig::_S_construct null not valid
/home/12Me22/scripts/restartminetest.sh: line 8: 1056 Aborted
#!/bin/bash
while true
do
sleep 1
minetestserver --config /home/12Me22/minetest/minetest.conf --world /home/12Me22/minetest/worlds/world \
--logfile /home/12Me22/backups/debug.txt
done
Last edited by 12Me22 on Sat May 04, 2013 16:26, edited 1 time in total.
Re: Automatic Server Restart Script
Someone tell me how to do it
- orwell
- Member
- Posts: 958
- Joined: Wed Jun 24, 2015 18:45
- GitHub: orwell96
- IRC: orwell96_mt
- In-game: orwell
- Location: Raxacoricofallapatorius
Re: Automatic Server Restart Script
If it's still relevant: you might want to have a look at https://github.com/orwell96/minetest_server_initd
Who is online
Users browsing this forum: No registered users and 10 guests