Difference between revisions of "Server auto restart"

From Armagetron
(Restart servers and reconnect to the master list automatically)
 
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
Ok, for a while after I started my own server, I needed it to restart every so often, to avoid lagginess, and to recconect to the master list. So I asked Avl.:C10ud (ianthetechie) for some help. Use this script he gave me:
 
Ok, for a while after I started my own server, I needed it to restart every so often, to avoid lagginess, and to recconect to the master list. So I asked Avl.:C10ud (ianthetechie) for some help. Use this script he gave me:
<br><code>#!/usr/bin/perl -w
+
<br><code>#!/usr/bin/perl -w<br><br>$checkline = `ps -e | grep dedicated | grep -v grep`;<br>unless ($checkline =~ /armagetronad-dedicated/) {<br> system "<i>whatever you use to start your server</i> -d >/dev/null 2>&1 &";<br>}</code>
 
<br><br>
 
<br><br>
$checkline = `ps -e | grep <i>your username</i> | grep dedicated | grep -v grep`;<br>
 
unless ($checkline =~ /armagetronad-dedicated/) <br>
 
system "<i>whatever you use to start your server</i> -d >/dev/null 2>&1 &";<br>
 
}<br>
 
</code>
 
<br>
 
 
Of course changing <i>your username</i> and <i>whatever you use to start your server</i> correctly. I edited this code slightly, if you are using BSD you may need to change "ps -e" to "ps auxwww".
 
Of course changing <i>your username</i> and <i>whatever you use to start your server</i> correctly. I edited this code slightly, if you are using BSD you may need to change "ps -e" to "ps auxwww".
 
Now, save this somewhere, do <br>
 
Now, save this somewhere, do <br>
 
<code>$ chmod a+x /path/to/it.pl</code><br>
 
<code>$ chmod a+x /path/to/it.pl</code><br>
 
so you can execute it, and add the crontab<br>
 
so you can execute it, and add the crontab<br>
<code>* * * * * /path/to/it</code>.<br>
+
<code>0-59 * * * * /path/to/it</code>.<br>
 
Then, when you get this to work, add or change in settings_dedicated.cfg<br>
 
Then, when you get this to work, add or change in settings_dedicated.cfg<br>
 
<code>DEDICATED_IDLE <i>#</i></code><br>
 
<code>DEDICATED_IDLE <i>#</i></code><br>
 
<i>#</i> being the number of hours before restarting.
 
<i>#</i> being the number of hours before restarting.
 
<br><br>Someone should really re-write this, its a little confusing.
 
<br><br>Someone should really re-write this, its a little confusing.
 +
 +
[[Category:Administration]]

Latest revision as of 18:37, 23 August 2021

Ok, for a while after I started my own server, I needed it to restart every so often, to avoid lagginess, and to recconect to the master list. So I asked Avl.:C10ud (ianthetechie) for some help. Use this script he gave me:
#!/usr/bin/perl -w

$checkline = `ps -e | grep dedicated | grep -v grep`;
unless ($checkline =~ /armagetronad-dedicated/) {
system "whatever you use to start your server -d >/dev/null 2>&1 &";
}


Of course changing your username and whatever you use to start your server correctly. I edited this code slightly, if you are using BSD you may need to change "ps -e" to "ps auxwww". Now, save this somewhere, do
$ chmod a+x /path/to/it.pl
so you can execute it, and add the crontab
0-59 * * * * /path/to/it.
Then, when you get this to work, add or change in settings_dedicated.cfg
DEDICATED_IDLE #
# being the number of hours before restarting.

Someone should really re-write this, its a little confusing.