( search forums )
php server start/stop script
Soldat Forums - Soldat Talk - Developers Corner
September 14, 2005, 10:33 pm
did someone writen a simple start/stop script?
mine isnt working :/
here my code
[code]system('screen -dmS '.$_SESSION['sname'].' '.$_SESSION['spath'].'/soldatserver');
so in the end it looks like
[code]system('screen -dmS test /var/www/server/soldatserver');
typin in this command in my ssh-console the server starts, but when performin this php-script the command "ps aux" only shows this: quote:www-data 849 0.0 0.1 2584 1156 ? S 22:58 0:00 SCREEN -dmS test2 /var/www/server/soldatserver
www-data 851 0.0 0.0 0 0 ? Z 22:58 0:00 [screen <defunct>]
the server didnt start :'(
plz help =)

September 14, 2005, 10:38 pm
Readt the manual... http://ar2.php.net/manual/en/ref.exec.php

Im not to shur but i think you should use shell_exec(). I'm n00bface, flieslikeabrick or enesce know how to fix this.

September 14, 2005, 10:47 pm
i read it and as far as i understood it it should work :/
it tried shell_exec()too, but the same result.

i think its the safe_mode on this root :/

September 14, 2005, 10:49 pm
Maybe you don't have the right permissions to run the file? I think when it's executed with a php script, the user apache executes it. At least that was the problem when I tried it.

September 14, 2005, 10:51 pm
all serverfiles are chmoded to 777, this should not be the problem =)
hmm but safe-mode isnt active, is it?
quote:safe_mode Off Off
safe_mode_exec_dir /usr/local/php/bin /usr/local/php/bin
safe_mode_gid Off Off

Deleted User
September 15, 2005, 2:50 am
Heres the code I used for my PHP-Commander script.
$cmd = $_SESSION['spath'].'/soldatserver >/dev/null &';
$return = exec($cmd, &$output, &$return_var);
Worked 100% fine, server ran for many hours. Untill it crashed >_>

Hope it works ^_^

September 15, 2005, 7:18 am
isn't psaux the ps/2 mouse device node?

Deleted User
September 15, 2005, 10:29 am
wtf? 'ps aux' is a linux command to list all running processes...

September 15, 2005, 12:42 pm
mhhhh it doesnt work :(
$output and $return_var are resulting 0
why i have always the strangest servers -.-

September 15, 2005, 1:09 pm
quote:Originally posted by Kageisn't psaux the ps/2 mouse device node?
/dev/psaux was the mouse device in pre-2.6 kernels. In 2.6 it was replaced by /dev/input/mice. `ps aux`, however, is a command to list the running processes.

October 20, 2005, 3:59 am
Have the same problem ... and how to kill or stop a soldat server. I have many server on this machine. I search for "kill commandline" but find nothing.

October 20, 2005, 11:20 am
i solved my problem with those scripts
$cmd= $_SESSION['spath'].'/soldatserver > /dev/null 2> /dev/null &';
$return = exec($cmd, &$output, &$return_var);
exec('exit', &$output, &$return_var);

echo "Server gestartet <br>";

} elseif($_GET['action']=='stop')
exec('ps ax |grep '.$_SESSION['spath'], &$output, &$return_var);
$kipid = $output[0];
$kipidi = explode(' ',$kipid);
exec('kill '.$kipidi[1]);
echo 'Server stopped';//('.$kipidi[0].', '.$kipidi[1].')<br>';