Author Topic: SRB (Soldatserver Restart Bashscript) v1.0  (Read 7471 times)

0 Members and 1 Guest are viewing this topic.

Offline Shoozza

  • Retired Soldat Developer
  • Veteran
  • ******
  • Posts: 1631
  • Soldat's Babysitter
    • Website
SRB (Soldatserver Restart Bashscript) v1.0
« on: August 23, 2009, 08:23:50 am »
Note:
I'm using this script on my GNU/Linux Soldatservers and never intended to release it here.
But since I have been asked if I could share it I am posting it here for everyone.
It doesn't work on windows unless you find a way to run bashscripts and crontab there.
However if you are on windows you can use my older tool SARS. It is similar to SRB but also written in perl.

What does it?
It simply restarts the soldatserver if it was closed.
The script may restart the server if it crashes but not if it is hanging.
I was made to work with more then one soldatserver (I use it for 4 servers).

How to setup?
Take a look at the README.txt.
It might be a bit challenging to setup but I hope the readme file is helpful enough.

Feedback is welcome.
« Last Edit: September 15, 2009, 02:26:16 pm by Shoozza »
Rules
Tools: ARSSE - SARS - SRB - chatMod

Offline Stuffy

  • Soldier
  • **
  • Posts: 182
  • Very stuffy.
    • Climb-Zone Forum
Re: SRB (Soldatserver Restart Bashscript) v1.0
« Reply #1 on: August 23, 2009, 08:50:27 am »
Thanks very much  :)
The truth is out there? Does anyone know the URL?
The URL is here

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Macellan
Re: SRB (Soldatserver Restart Bashscript) v1.0
« Reply #2 on: August 23, 2009, 06:36:56 pm »
Thank you. I never get a stable work with SARS.
« Last Edit: August 05, 2012, 05:57:47 pm by xmRipper »
CoFounder / CTO @ Macellan
Founder Turkish Soldat Community

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5007
Re: SRB (Soldatserver Restart Bashscript) v1.0
« Reply #3 on: August 24, 2009, 03:48:03 pm »
Cool. Added to Fan Apps list.

It doesn't work on windows unless you find a way to run bashscripts and crontab there.
cygwin?
Careful with that axe, Eugene.

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Macellan
Re: SRB (Soldatserver Restart Bashscript) v1.0
« Reply #4 on: August 24, 2009, 06:19:58 pm »
Just use FireDaemon Pro on Windows.
CoFounder / CTO @ Macellan
Founder Turkish Soldat Community

Offline Fir3wall

  • Major(1)
  • Posts: 4
    • PolAng
Re: SRB (Soldatserver Restart Bashscript) v1.0
« Reply #5 on: July 06, 2018, 03:34:25 pm »
Hi all i Know i had warning to type new post i just wonder if this still works or is there new way to keep server running from time to time server becomes dead even ARSE does not wake up server just hard restart.

Is there solution to keep server alive?

Hope to get helpful answer.

Thank you in advance.

Tried to run this plugin on 1.7.1 server files but comes back as Server folder does not exist / even it is actual server file location. /home/"username"/Desktop/dmsoldat/soldatserver1

I know we got to many servers and not enough players please consider my will. Worst case will power down and leave it as it is. Reading forum some posts shout not take place to be accessible to public.

Just so all know every one has it's own opinion bear this in mind.

Thanks again.

Offline Moroes

  • Soldier
  • **
  • Posts: 161
Re: SRB (Soldatserver Restart Bashscript) v1.0
« Reply #6 on: July 07, 2018, 01:36:24 am »
I was told once people use zakath's manager. So maybe give that a try https://forums.soldat.pl/index.php?topic=33867.0

As for the clear and easy solution. You could try this php code we've always used back on SNI Climb servers. All you need is probably just a PHP package installed, some cronjob running it or so, bash script for the server launch options and ofc editting path to server and the ip/port.

Code: [Select]
#!/usr/bin/php
<?php

$fs 
fsockopen('SERVER_IP'SERVER_PORT$errno$errstr1);
if (
$fs) {
// server is running
echo "Server is running\n";
fclose($fs);
exit;
}

echo 
"Server is not running, attempting to restart\n";

// check if the process is already running (ghost process)
exec('ps x | grep soldatserver | grep -v grep'$output);
//echo "o: $output[0]";
if ($output) {
// ghost process of the server is running; kill it
echo "Killing old process\n";
list($pid) = preg_split('/\s+/'$output[0]);
exec('kill -KILL '.escapeshellarg($pid));
// sleep for a couple of seconds to be sure that the process is killed
sleep(10);


}

// start the server
echo "Starting server\n";
if(!(
$fs)){
exec('/PATH/TO/BASH/SCRIPT');
}
Credits: Bloo (I guess  ;D)

Example of launch script
Code: [Select]
#!/bin/bash
cd /path/to/server/folder
./soldatserver >/dev/null 2>&1 &

Offline Fir3wall

  • Major(1)
  • Posts: 4
    • PolAng
Re: SRB (Soldatserver Restart Bashscript) v1.0
« Reply #7 on: July 07, 2018, 06:11:18 pm »
Hi thanks for giving me the script but i get this error message

Code: [Select]
PHP Warning:  fsockopen(): unable to connect to 127.0.0.1:23074 (Connection refused) in /home/username/Desktop/scripts/startscript on line 4
 

No matter what ip i use i get same error again and again.

Question 1 is the server got to be online in order for this script to work ?.

Script read out server online no need to restart or start but server was running but what about if server died ? will it not recover ?

Server on, script reacts to it but server off, and i want script to kick in the server this is what i get as described above.

Unless script will work under some condition where the server already runs and does not respond so it will restart due to idling of the process.

Script also says if already alive kill it wait 10s and process new Job ( process ).

Or simply I'm doing something wrong and I do admit to it :P

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5007
Re: SRB (Soldatserver Restart Bashscript) v1.0
« Reply #8 on: July 08, 2018, 05:19:21 pm »
That script works by first checking if the server is online, and if it is, it just bails. If you don't want that warning, you can put a @ before the fsockopen call, like @fsockopen( and php will suppress the warning.

Also, instead of using that one liner with ps x and grep and so on, you can simply kill all running soldatservers on Linux with: pkill -9 -f soldatserver
Careful with that axe, Eugene.

Offline Fir3wall

  • Major(1)
  • Posts: 4
    • PolAng
Re: SRB (Soldatserver Restart Bashscript) v1.0
« Reply #9 on: July 09, 2018, 02:44:11 pm »
Thank you for your reply will give it a go and will edit this post to update on status thanks again to everyone for the support.