Not only is this a repetitive and tiresome process, but it also kills your players morale. Your server starts getting popular, players are having a good time and BAM, no more server. This especially kicks in if you're limited on funds and can't afford a server where you have more control.
Well, a small solution is to relaunch DreamDaemon automatically. And here is a small script I whipped up to do so.
<?
$port_num = 55678; //The port in which you want to host the game on.
$a = shell_exec("netstat -nlt | grep $port_num"); //Check to see if that port is already in use. Or DreamDaemon is still running.
if(!$a) { //If it isn't, relaunch DreamDaemon.
popen("DreamDaemon path/to/your/game.dmb $port_num -trusted &", "r");
}
?>
Now that works all fine and dandy, but what about automating that script for a set time limit. I attempted to do this using a Cron Job. But it didn't work. (Audeuro has an untested script to make it work, and once I've tested that, I'll post it here.)
Automating the script needed a finer approach. Seeing as CronDaemon wasn't successfully doing it, I needed something else to kick in. And that's where I sought assistance from BYOND's local Python Guru, Crashed.
With a little script he whipped up (able to work with Python 2.2 and onwards) we were able to automate it.
from time import sleep
import os
while True:
os.popen('php my_php_file.php')
sleep(1800) #seconds
To execute the script, open up your command line client (in my case, PuTtY) and execute it like so: python my_python_file.py &
If the BYOND server isn't running, you'll receive DreamDaemon's execution message. Then type exit and logout.
Now, that script there will run your PHP script every half an hour to check up on your DreamDaemon. Ever looking to improve it, I'll be revising this script at a later date to check on it all. But at the moment, that should do the trick (it's working so far for me).
I should also say, that script will only work provided both the python and php script are inside your root folder (that is, the one before public_html).
Thanks
Winchester