Re: Try to find a solution, when restart Apache with PHP Script

From: Date: Tue, 18 Sep 2007 11:16:26 +0000
Subject: Re: Try to find a solution, when restart Apache with PHP Script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-262195@lists.php.net to get a copy of this message
Daevid, understood... but in my case the php script is called once one time, and then keep's on running "forever" on a server background shell... The user never will have to worry about the process again, but if the process is not running on the server a message will apear on the interface or a email will be send to the administrator (me and others)... The best solution for me will be the possibility of running this PHP script on other port than the default using by apache. Thanks Daevid Vincent escreveu:
We put a timeout at the top and show an error if the server never comes back. You could do whatever you want. As long as the user doesn't try to refresh the page or go somewhere else on your server, the ajax will just keep trying in the background. That's all client-side JS / AJAX.
-----Original Message----- From: Rodolfo De Nadai [mailto:rodolfo.denadai@ima.sp.gov.br] Sent: Monday, September 17, 2007 1:00 PM To: Daevid Vincent Cc: php-general@lists.php.net Subject: Re: [PHP] Try to find a solution, when restart Apache with PHP Script Hi Daevid, This app keep alive forever as well? When you restart apache what happend to your app? Daevid Vincent escreveu:
    
-----Original Message----- From: Rodolfo De Nadai [mailto:rodolfo.denadai@ima.sp.gov.br] Sent: Monday, September 17, 2007 5:25 AM
To: php-general@lists.php.net Subject: [PHP] Try to find a solution, when restart Apache with PHP Script Hi all... I'm facing a serious problem with my application. I have a script write in PHP that starts in Internet Explorer, this script keep
        
on running
until a varible value change on my MySQL database. The problem is that when i restart Apache, the process child initalized isn't kill... then the apache can't be start because the
script is use
the port 80. To solve my problem, without change anything, the best
        
would be that
when i execute the script, it run on other port than the
default 80...
so this way apache could start... The is a way to redirect through php, so the script run on
a diferent
port?? Like change some line, or add on php.ini files?? or even in programming?? thanks ... for any info
            
We do something like this, wherein sometimes we have to
force a restart of
Apache, so in order to not kill the web page for the GUI,
we use AJAX to
continually poll the server. Then when the server is back,
we can issue a
page refresh to whatever page we want... ---------------------------8< snip
      
8----------------------------------------
<?php
$request_interval = 10000; // 10 seconds. $type = intval( $_GET[ 'type' ] ); if ( 1 == $type ) { $initial_wait = 60000; // 1 minute. $title = translate('Rebooting Appliance'); $text = translate('This may take several
      
minutes. If this
page does not redirect you, click <A
HREF="home_start_main.php">here</A>.');
} else { $initial_wait = 20000; // 20 seconds. $title = translate('Rebuilding Web Certificates'); $text = translate('If this page does not
      
redirect you in a
few seconds, click <A HREF="home_start_main.php">here</A>.'); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <TITLE><?= translate('%1$s :: Loading...',
      
PRODUCT_fENF) ?></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;"> <LINK REL="STYLESHEET" TYPE="text/css" HREF="includes/default.css?version=1"> </HEAD> <BODY> <TABLE WIDTH="100%" HEIGHT="100%"> <TR> <TD ALIGN="center" VALIGN="middle" HEIGHT="100%" WIDTH="100%"> <TABLE BORDER="0" CLASS="componentBox"> <TR VALIGN="middle"> <TD COLSPAN="3" CLASS="tableHeadline"><?=$title?></TD> </TR> <TR VALIGN="MIDDLE"> <TD><IMG SRC="images/icons/paper_time.gif"></TD> <TD> <TABLE> <TR> <TD><?=$text?></TD> </TR> <TR>
      
<TD
ALIGN="CENTER"><DIV ID="status" STYLE="color:gray"><?= translate('Waiting...') ?></DIV></TD> </TR> </TABLE> </TD> </TR> </TABLE> </TD> </TR> </TABLE> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- var xmlhttp=false; var id, state = 0; var initial_wait = <?=$initial_wait?>; // JScript gives us Conditional compilation, we can cope with old IE versions. // and security blocked creation of the objects. try { xmlhttp = new ActiveXObject( "Msxml2.XMLHTTP" ); } catch ( e ) { try { xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" ); } catch ( E ) { xmlhttp = false; } } if ( !xmlhttp && typeof XMLHttpRequest != 'undefined' ) { xmlhttp = new XMLHttpRequest(); } function try_url() { if ( 0 == state ) { document.getElementById( "status" ).innerHTML = "<?= translate('Requesting page...') ?>"; xmlhttp.open( "HEAD",
      
"home_start_main.php",
true ); xmlhttp.onreadystatechange=function() { state = xmlhttp.readyState if ( 4 == state ) { // Needed this try/catch block for Firefox. var httpstatus; try { httpstatus = xmlhttp.status; } catch ( e ) { httpstatus = -1; } if( (
      
httpstatus == 200 ) ||
( httpstatus == null ) || ( httpstatus == 0 ) || (
httpstatus == 304 ) )
{ state = 0; document.getElementById( "status" ).innerHTML = "<?=
      
translate('Request
succeeded...') ?>";
      
self.clearInterval(
id );
      
document.location =
'home_start_main.php'; } else { document.getElementById( "status" ).innerHTML = "<?=
      
translate('Request
failed...') ?>"; state = 0; } } } xmlhttp.send( null ) } } function start_polling() { initial_wait = initial_wait - 1000; if ( initial_wait <= 0 ) { self.clearInterval( id ); document.getElementById( "status" ).innerHTML = "<?= translate('Requesting page...') ?>"; try_url(); id = self.setInterval( 'try_url()', <?=$request_interval?> ); } else { document.getElementById( "status" ).innerHTML = "<?= translate('Waiting ') ?>" + (
      
initial_wait / 1000 ) +
"..."; } } id = self.setInterval( 'start_polling()', 1000 ); //--> </SCRIPT> </BODY> </HTML>
      
-- * Rodolfo De Nadai * * Analista de Sistema Jr. - Desenvolvimento * *Informática de Municípios Associados S.A.* Seu governo mais inteligente rodolfo.denadai@ima.sp.gov.br <mailto:rodolfo.denadai@ima.sp.gov.br> - www.ima.sp.gov.br <http://www.ima.sp.gov.br/> Fone: (19) 3739-6000 / Ramal: 1307
    
-- * Rodolfo De Nadai * * Analista de Sistema Jr. - Desenvolvimento * *Informática de Municípios Associados S.A.* Seu governo mais inteligente rodolfo.denadai@ima.sp.gov.br <mailto:rodolfo.denadai@ima.sp.gov.br> - www.ima.sp.gov.br <http://www.ima.sp.gov.br/> Fone: (19) 3739-6000 / Ramal: 1307

« previous php.general (#262195) next »