| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 75904 | 2007-01-14 06:13:00 | Streaming Media & PHP help: Checking if pythons running, and if not, starting an app | Chilling_Silence (9) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 515722 | 2007-01-14 06:13:00 | Hi all, Im running www.teatatubaptist.com and as part of it Im also putting up recorded messages. One redirection URL is currently taking visitors to the "messages" streaming section using the following code in the page Header: <script type="text/javascript"> <!-- document.location="http://teatatubaptist.com:8089"; //--> </script> Aaaanyways, Im using edna to stream the media files and Ive made a .php file that I can call that simply contains: <?php shell_exec("nohup python edna.py"); ?> However if its already running then it spawns another instance of it. What I want to do somehow is get it to run a check and see if python is already running, and if it is, then redirect to http://teatatubaptist.com:8089.. but if its not, then to run 'python edna.py' to spawn the server and then redirect them. Any suggestions would be much appreciated Cheers Chill. |
Chilling_Silence (9) | ||
| 515723 | 2007-01-14 10:56:00 | I remember this problem.... use shell_exec() or similar to run top, and then run preg_match() on the result in order to check if python is running. Another solution would be checking if there is a pidfile for python, but as I don't know how to do that I can't help on that point. But the top solution would definitely work. |
Erayd (23) | ||
| 515724 | 2007-01-15 07:37:00 | Any suggestions on the actual code? :D I tried to get onto the PHPUG, but it kept on rejecting me for some reason? |
Chilling_Silence (9) | ||
| 515725 | 2007-01-15 10:55:00 | Why not execute the script in the background, doing so will give you a job number and the PID that you could capture from the output and check against to see if the script is still running, etc. I'm not on Linux to actually test this theory though, but when I do get back to it, I will test it out. Cheers, KK |
Kame (312) | ||
| 515726 | 2007-01-15 12:44:00 | When you say 'execute from the background' do you mean from the shell? Its a possibility, Id thought of having it check for a .pid file perhaps? | Chilling_Silence (9) | ||
| 1 | |||||