|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 -- * 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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
> 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?? > The TCP port used is configured by Apache. You can't change this in PHP. In any case, I very much doubt it would solve your problem since it will still be blocking on whatever port you use. To resolve this issue, you need to work on why IE is holding the connection open. Perhaps a better solution is to simply have the client poll a PHP script to determine when desired condtion occurs. Edward |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Edward , my best guess is that not IE is holding the connection but the
apache user... because the process is related to the apache user... and there's more i can close IE, bacause i use the directive 2> log.log & on the call of system. Example: system("php myscript.php 2> log.log &"); This why IE will not wait until the script is finish... One thing i can't understand is why this child process of the apache user is not killed when i restart apache... that's the real deal... thanks Edward Kay escreveu: >> 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?? >> >> > The TCP port used is configured by Apache. You can't change this in PHP. In > any case, I very much doubt it would solve your problem since it will still > be blocking on whatever port you use. > > To resolve this issue, you need to work on why IE is holding the connection > open. Perhaps a better solution is to simply have the client poll a PHP > script to determine when desired condtion occurs. > > Edward > > > > -- * 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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Rodolfo De Nadai wrote:
> Edward , my best guess is that not IE is holding the connection but the > apache user... because the process is related to the apache user... and > there's more i can close IE, bacause i use the directive 2> log.log & on > the call of system. > Example: > system("php myscript.php 2> log.log &"); > This why IE will not wait until the script is finish... > > One thing i can't understand is why this child process of the apache > user is not killed when i restart apache... that's the real deal... > > thanks > This doesn't actually start a new process of PHP seperate from Apache. What you are doing is starting a child process of the child process or the root process of Apache. What you might want to look in to is http://us2.php.net/manual/en/ref.pcntl.php This will you fork your processes, but I think you are still going to run into the same problem even if you fork it within the php process of apache. What you are probably going to need to do is create your own custom script that will act as a daemon, and replace apache altogether. This way it is completely separate from apache. It can run on its own port and only answer to you. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Jim, i've already look for pcntl... but the support server guys, tell me
that they can't install php modules that are not pre-compiled... so, pcntl is not an alternative... I think you are right... i have to make this script a daemon... but how can i do that with php??... the problem is that this daemon should be started in web interface... see the problem...??? thanks Jim Lucas escreveu: > Rodolfo De Nadai wrote: >> Edward , my best guess is that not IE is holding the connection but >> the apache user... because the process is related to the apache >> user... and there's more i can close IE, bacause i use the directive >> 2> log.log & on the call of system. >> Example: >> system("php myscript.php 2> log.log &"); >> This why IE will not wait until the script is finish... >> >> One thing i can't understand is why this child process of the apache >> user is not killed when i restart apache... that's the real deal... >> >> thanks >> > > This doesn't actually start a new process of PHP seperate from > Apache. What you are doing is starting a child process of the child > process or the root process of Apache. > > What you might want to look in to is > http://us2.php.net/manual/en/ref.pcntl.php > > This will you fork your processes, but I think you are still > going to run into the same problem even if you fork it within the php > process of apache. > > What you are probably going to need to do is create your own custom > script that will act as a daemon, and replace apache altogether. > > This way it is completely separate from apache. It can run on its own > port and only answer to you. > -- * 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 |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Rodolfo De Nadai wrote:
> Jim, i've already look for pcntl... but the support server guys, tell me > that they can't install php modules that are not pre-compiled... so, > pcntl is not an alternative... > Bummer, get new support server guys... no, but really.... > I think you are right... i have to make this script a daemon... but how > can i do that with php??... the problem is that this daemon should be > started in web interface... see the problem...??? Well, both windows and *nix have ways of running different apps as a daemon. I actually wrote a little daemon that listens for UDP connections on a given port and takes care of all incoming connections. What do you mean "should be started in web interface" ? Does this mean that it should only be running when you connect to it with a web browser? > > thanks np -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
No... it not should only run when i'm connected to it throught a web
server... it means that when i go to specific IE page and press a button named 'Enable' the daemon should be called and start to run indefinitly, and i'm able to close IE session and the daemon keep working as well... That's what i mean... Jim Lucas escreveu: > Rodolfo De Nadai wrote: >> Jim, i've already look for pcntl... but the support server guys, tell >> me that they can't install php modules that are not pre-compiled... >> so, pcntl is not an alternative... >> > > Bummer, get new support server guys... no, but really.... > >> I think you are right... i have to make this script a daemon... but >> how can i do that with php??... the problem is that this daemon >> should be started in web interface... see the problem...??? > > Well, both windows and *nix have ways of running different apps as a > daemon. > > I actually wrote a little daemon that listens for UDP connections on a > given port and takes care of all incoming connections. > > What do you mean "should be started in web interface" ? Does this > mean that it should only be running when you connect to it with a web > browser? > >> >> thanks > > np > -- * 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 |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
Rodolfo De Nadai wrote:
> No... it not should only run when i'm connected to it throught a web > server... > it means that when i go to specific IE page and press a button named > 'Enable' the daemon should be called and start to run indefinitly, and > i'm able to close IE session and the daemon keep working as well... > > That's what i mean... Well, in that case, what you could do is have a cron job, or if on windows some form of scheduled task, that looks for a file that indicates that it should be running. Then from apache, you could setup a page that has your enable button. When submitted, it creates a file that indicates to the above scheduled task that it needs to run. Then, when that scheduled task starts, it looks at the file and sees that it needs to be running, then it stays running. It checks to see if it has a pid file already created. if it cannot find a pid file, it creates a pid file to indicate that it is running. It checks every once in a while to see if the file that tells it that it needs to be running it still there, once that file goes away, it kills the pid file and kills itself too. Then the scheduled jobs keeps checking... You might find that you need to do a little refinement to this process. But, this is where I would start. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
Right on the moment this process is not a option... because the project
should end in 4 weeks... perhaps after a while i could try use this ideia of yours... But right now i have to find a diferent solution... But thanks Jim... that open new horizons... Jim Lucas escreveu: > Rodolfo De Nadai wrote: >> No... it not should only run when i'm connected to it throught a web >> server... >> it means that when i go to specific IE page and press a button named >> 'Enable' the daemon should be called and start to run indefinitly, >> and i'm able to close IE session and the daemon keep working as well... >> >> That's what i mean... > > Well, in that case, what you could do is have a cron job, or if on > windows some form of scheduled task, that looks for a file that > indicates that it should be running. > > Then from apache, you could setup a page that has your enable button. > When submitted, it creates a file that indicates to the above > scheduled task that it needs to run. > > Then, when that scheduled task starts, it looks at the file and sees > that it needs to be running, then it stays running. It checks to see > if it has a pid file already created. if it cannot find a pid file, it > creates a pid file to indicate that it is running. It checks every > once in a while to see if the file that tells it that it needs to be > running it still there, once that file goes away, it kills the pid > file and kills itself too. > > Then the scheduled jobs keeps checking... > > You might find that you need to do a little refinement to this > process. But, this is where I would start. > > -- * 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 |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
> -----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> |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#12 |
|
Messages: n/a
Hébergeur: |
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 > > |
|
|
|
#13 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#14 |
|
Messages: n/a
Hébergeur: |
On 9/17/07, Rodolfo De Nadai <rodolfo.denadai@ima.sp.gov.br> wrote:
> 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. Hi Rodolfo- I think you are going about this the wrong way. You shoud not have the PHP script itself execute the forever running task, it should just trigger the separate starting/stopping of the task. There are several ways to do this, the first two that spring to mind are: 1. Create a custom init-script in /etc/init.d (or wherever your distribution has init scripts) that the PHP process triggers with a start command (/etc/init.d/myprog start). This will require root privileges for the PHP process (or no-password sudo privileges for that command). --or-- 2. Have a cron job running as a user that has appropriate permissions. This cron job should look for the presence of specific files - if it sees them, it takes the appropriate action, and then deletes the trigger file. For example, have the cron job watch for the presence of /tmp/startMyProg.marker - when it sees it, it starts the program and deletes /tmp/startMyProg.marker. Also have it watch for the presence of /tmp/stopMyProg.marker, when it sees that, it would stop the running program, and delete the marker file. At this point, all your PHP script has to do is create the appropriate file in /tmp (could be as simple as a exec("touch /tmp/startMyProg.marker") call). Hope that sends you a workable direction- James |
|
|
|
#15 |
|
Messages: n/a
Hébergeur: |
Hello James,
in future we will implement the script with cron, i've already talk to the support server guys... and i think this would be the best pratice... But for now i was wondering if there's a workaround... because in the moment my boss tell me to not change anything that could delay the software more than 1 or 2 days... So i'm looking for a dirty solution for now... thanks James Ausmus escreveu: > On 9/17/07, Rodolfo De Nadai <rodolfo.denadai@ima.sp.gov.br> wrote: > >> 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. >> > > Hi Rodolfo- > > I think you are going about this the wrong way. You shoud not have the > PHP script itself execute the forever running task, it should just > trigger the separate starting/stopping of the task. There are several > ways to do this, the first two that spring to mind are: > > 1. Create a custom init-script in /etc/init.d (or wherever your > distribution has init scripts) that the PHP process triggers with a > start command (/etc/init.d/myprog start). This will require root > privileges for the PHP process (or no-password sudo privileges for > that command). > > --or-- > > 2. Have a cron job running as a user that has appropriate permissions. > This cron job should look for the presence of specific files - if it > sees them, it takes the appropriate action, and then deletes the > trigger file. For example, have the cron job watch for the presence of > /tmp/startMyProg.marker - when it sees it, it starts the program and > deletes /tmp/startMyProg.marker. Also have it watch for the presence > of /tmp/stopMyProg.marker, when it sees that, it would stop the > running program, and delete the marker file. At this point, all your > PHP script has to do is create the appropriate file in /tmp (could be > as simple as a exec("touch /tmp/startMyProg.marker") call). > > Hope that sends you a workable direction- > > James > > > -- * 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 |
|
![]() |
| Outils de la discussion | |
|
|