Re: Disowning apache processes

From: Date: Mon, 08 Mar 2004 20:43:31 +0000
Subject: Re: Disowning apache processes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-179818@lists.php.net to get a copy of this message
>I am writing a control panel for a gamehost using PHP, which calls a bash >script (which wraps around another) to control game servers > >Right now once the bash scripts are running the PHP script that called >them is unavailable for any more users, and if apache is restarted the >bash script is killed You may want to investigate the (currently) experimental PCNTL extension in PHP - it provides support for forking, which is the usual way to handle daemons like this. Another option is to simply write a daemon, and pass commands to it via a socket or spawn new instances upon request. This should be fairly easy using Perl, and it allows you to decouple your webserver from the inner workings of your game host, and have leaner forked processes (no need to have the full overhead of an apache child process to run a game host, I assume). >Here's the code so far: > >[the php file] > >case "start": exec('bash -c "exec nohup ./run2 > /dev/null 2>&1 >&"'); I think the trivial fix here is to stick that last '&' outside the '"', so that the bash process drops into the background. --------------------------------------------------------------------- michal migurski- contact info and pgp key: sf/ca http://mike.teczno.com/contact.html

« previous php.general (#179818) next »