Oh I made a mistake. the case I wrote will restart, when the server is responding. You could use the code with a cronjob and without the while loop:

#!/bin/bash

if [[ "`printf '\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00' | netcat -u -w 1 $IP $PORT`" == "" ]]
 then
  sleep 10
if [[ "`printf '\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00' | netcat -u -w 1 $IP $PORT`" == "" ]]
   then
    stop_server
    start_server
  fi
fi


Am 26.05.2011 17:44, schrieb Ulrich Block:
while true
    do
if [[ `printf '\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00' | netcat -u -w 1 ip port` ]]
    then
        yourrestartfunction
    fi
    sleep 60
done

Am 26.05.2011 16:07, schrieb Eric Riemers:
Something like this is possible, however our servers are on multiple boxes too. A crontab that checks my database to see if somebody issues a "kill" and then act upon it would be the best solution so far. I would manage to do
this in php or perl..  but it won't be nice... :)

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Daniel Vogel
Sent: donderdag 26 mei 2011 14:44
To: Half-Life dedicated Linux server mailing list
Subject: Re: [hlds_linux] remote restart of screen session?

I'm using a web interface for my servers I made in PHP and I experienced
similar issues with freezing servers not being able to be shut down by any
admin except me (via ssh). The solution I use is simple.
Since my web interface names all screens it starts tf_$id (like tf_15) I can simply provide a kill switch which would use `ps aux | grep tf_15` to get the PID of the screen and then kill it, all in one bash script which simply
takes the server id as parameter.
So if you give your screens unique names it's only one PHP and bash script
that finds and kills the server.

--
Mit freundlichen GrĂ¼ssen,
Sincerely Yours,
Daniel Vogel



On 26 May 2011 13:31, frostschutz<[email protected]>  wrote:
On Thu, May 26, 2011 at 10:33:23AM +0200, Eric Riemers wrote:
Only in some cases the instance "hangs" and needs a proper kill or
something similar to restart.
If there's any way to reliably detect these hangs, some kind of
watchdog cron job that restarts it automatically might be worth
looking into.

Finding out the cause of those hangs&  fixing those would be even
better but you can't have everything I guess... :)

I could create a webthingy that it places a file which can be checked
with a crontab and if found restart a screen/process but it sounds
like someone should have been there before me.
For running / managing gameservers and other things in screen, I made
this:
https://github.com/frostschutz/Screen-Manager/blob/master/bin/sm

However it does not offer any kind of remote management.

If you already have a web service running on the machine, it'd
probably be the best / easiest to use option.

I used to have a Python daemon that allowed the client to connect
through telnet and issue simple commands like ping server, show players,
or restart.
I'm using SSH instead now, with an authorized_keys entry that
restricts the user to a specific action only, so it does not actually
give shell access. For example the entry can look like this:

command="manage-server.sh",no-agent-forwarding,no-port-forwarding,no-u
ser-rc,no-X11-forwarding ssh-rsa AAAAQQQQ== AdminName

Of course this requires the user to install an SSH client and generate
an SSH key, although you can hide this complexity behind a Windows
shortcut.
Still, a web service would probably be much more comfortable, I just
didn't want to install a web server and possibly PHP just for this...

Regards
frostschutz

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux



_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux



_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux

Reply via email to