Re: [fw-general] Continue Processing after an action is completed

2009-02-09 Thread Yannick Mortier
2009/2/8 A.J. Brown :
>
> Just append "&" to the end of the command.
>
> system('php -f /path/to/file.php var1 var2 &');
>
> It may not work on a share host either, though :)
>

The problem seems to be solved already, but to be complete I wanted to
add that this won't work either. You are right, the process will be
running in the background, but it'll also be cancelled when the script
is finished.
If you're running Linux at your PC you can try this out just open up a
console, start a gui application with the & at the end of the line and
close the console windows, the GUI application will close as well
(this does not apply for every GUI application, since some detach from
the console, but for the most I could reproduce this). This is because
they are still "connected" to the shell that you opened.

If you'd really want to detach a process you'd have to use something
like screen.

But as the problem is already solved this was just to give a hint to
everybody that was finding this discussion by using google.

-- 
Currently developing a browsergame...
http://www.p-game.de
Trade - Expand - Fight

Follow me at twitter!
http://twitter.com/moortier


Re: [fw-general] Continue Processing after an action is completed

2009-02-09 Thread Ashley McConnell



Matthew Weier O'Phinney-3 wrote:
> 
> 
>> 
>> I haven't been using PHP very long, so forgive me the silly question, but
>> what form would a queue processor take?  Is it a php script run as a
>> daemon? 
>> Is there a way for Zend to kick it off if it isn't running already?
> 
> Depends on the path you choose for the job queue, really. I've typically
> used cron to run my queue, but other options include having a daemon
> running in the background checking periodically for updates (and said
> daemon does not necessarily need to be written in PHP -- just needs to
> invoke your script that does the processing). Platform's Job Queue runs
> as a daemon, for instance.
> 
> You _don't_ want your web application to trigger it, as you'll run into
> the exact situation you were having before.
> 
> 

Thanks Matt and A.J.  I have used unix / linux in the past, but not really
regularly - I never thought of using cron to kick things off, but I guess
thats the most obvious thing :)

Thanks for the tips guys - I'll figure something out.  It has been a nice
welcome to the mailing list!

All the best,
Ash

-- 
View this message in context: 
http://www.nabble.com/Continue-Processing-after-an-action-is-completed-tp21900147p21909117.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Continue Processing after an action is completed

2009-02-08 Thread swilhelm

Store the data needed for further processing in some persistent queue and use
a cron job to poll the "further processing queue" on regular intervals.

- Steve W.


Ashley McConnell wrote:
> 
> Hi Folks,
> 
> I would like to be able to call an action / respond to the client and then
> continue on with some further processing.
> 
> I have tried a couple of things: -
> 
> Using fork: -
> http://www.php.net/manual/en/function.pcntl-fork.php
> 
> This doesn't work on my windows installation and i'm not sure it will be
> enabled on my hosting.
> 
> Using a headers hack method:-
> 
> http://www.brandonchecketts.com/archives/performing-post-output-script-processing-in-php
> 
> This seems to work the first time, but not the next time you call it.
> 
> Register Shutdown function
> http://uk2.php.net/register_shutdown_function
> 
> This doesn't work at all - it just blocks until the "other processing" is
> finished.
> 
> Is there anything that works with the Zend Framework? Any other ideas?
> 
> Thanks for your help
> All the best,
> Ash
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Continue-Processing-after-an-action-is-completed-tp21900147p21908043.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Continue Processing after an action is completed

2009-02-08 Thread Matthew Weier O'Phinney
-- Ashley McConnell  wrote
(on Sunday, 08 February 2009, 11:20 AM -0800):
> Matthew Weier O'Phinney-3 wrote:
> > From the above experiments you've tried, it sounds like you want to
> > offload some processing to occur after the content is delivered, but
> > want it to occur without keeping the connection to the client. With this
> > in mind, I'd suggest building a job queue. With this sort of solution,
> > you send a message to the queue, and then a queue processor queries it
> > periodically and performs routines pertinent to the message sent.
> > 
> > There is a Zend_Queue proposal under review, but not yet accepted. There
> > are also commercial solutions such as Zend Platform's Job Queue which
> > can perform this work. 
> > 
> > You can also roll your own, something I've done before myself. Usually,
> > you provide a callback, and the arguments for the callback, and your
> > queue processor then does the processing. I've done implementations that
> > used static class methods for the callbacks, as well as some that would
> > instantiate the given class and then call the given method with the
> > provided arguments (utilizing call_user_func_array()).
> 
> Thanks for your reply.  Sounds great, just as some background - what I am
> doing is uploading results from a race in my racing simulator - writing them
> to the db and then I am intending to do some processing to figure out if
> anyone broke any records or passed any milestone (1000 laps for example).
> 
> I haven't been using PHP very long, so forgive me the silly question, but
> what form would a queue processor take?  Is it a php script run as a daemon? 
> Is there a way for Zend to kick it off if it isn't running already?

Depends on the path you choose for the job queue, really. I've typically
used cron to run my queue, but other options include having a daemon
running in the background checking periodically for updates (and said
daemon does not necessarily need to be written in PHP -- just needs to
invoke your script that does the processing). Platform's Job Queue runs
as a daemon, for instance.

You _don't_ want your web application to trigger it, as you'll run into
the exact situation you were having before.

-- 
Matthew Weier O'Phinney
Software Architect   | matt...@zend.com
Zend Framework   | http://framework.zend.com/


Re: [fw-general] Continue Processing after an action is completed

2009-02-08 Thread A.J. Brown
This won't work on a windows host, but If you you can pass all of the proper
variables as arguments, You can try executing the task in the background via
shell in postDispatch.

Just append "&" to the end of the command.

system('php -f /path/to/file.php var1 var2 &');

It may not work on a share host either, though :)


On Sun, Feb 8, 2009 at 9:48 AM, Ashley McConnell
wrote:

>
>
>
> keith Pope-4 wrote:
> >
> > The thing that springs to mind is using the postDispatch on either the
> > Front Controller or the Action Controller
> >
> >
>
> Hi Keith,
>
> Thanks for the reply - I did try that actually, but it seems to run before
> the connection to the client is closed.  I tried a sleep(5) in there and
> the
> page took around 5 seconds to fully load, whereas without the postDispatch
> it was almost instant.
>
> All the best,
> Ash
>
> --
> View this message in context:
> http://www.nabble.com/Continue-Processing-after-an-action-is-completed-tp21900147p21900748.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>


-- 
A.J. Brown
web | http://ajbrown.org
phone | (937) 660-3969


Re: [fw-general] Continue Processing after an action is completed

2009-02-08 Thread Ashley McConnell



Matthew Weier O'Phinney-3 wrote:
> 
> 
> From the above experiments you've tried, it sounds like you want to
> offload some processing to occur after the content is delivered, but
> want it to occur without keeping the connection to the client. With this
> in mind, I'd suggest building a job queue. With this sort of solution,
> you send a message to the queue, and then a queue processor queries it
> periodically and performs routines pertinent to the message sent.
> 
> There is a Zend_Queue proposal under review, but not yet accepted. There
> are also commercial solutions such as Zend Platform's Job Queue which
> can perform this work. 
> 
> You can also roll your own, something I've done before myself. Usually,
> you provide a callback, and the arguments for the callback, and your
> queue processor then does the processing. I've done implementations that
> used static class methods for the callbacks, as well as some that would
> instantiate the given class and then call the given method with the
> provided arguments (utilizing call_user_func_array()).
> 
> 

Hi Matthew,

Thanks for your reply.  Sounds great, just as some background - what I am
doing is uploading results from a race in my racing simulator - writing them
to the db and then I am intending to do some processing to figure out if
anyone broke any records or passed any milestone (1000 laps for example).

I haven't been using PHP very long, so forgive me the silly question, but
what form would a queue processor take?  Is it a php script run as a daemon? 
Is there a way for Zend to kick it off if it isn't running already?

Thanks again for your help
All the best,
Ash
-- 
View this message in context: 
http://www.nabble.com/Continue-Processing-after-an-action-is-completed-tp21900147p21902316.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Continue Processing after an action is completed

2009-02-08 Thread Matthew Weier O'Phinney
-- Ashley McConnell  wrote
(on Sunday, 08 February 2009, 07:50 AM -0800):
> I would like to be able to call an action / respond to the client and then
> continue on with some further processing.
> 
> I have tried a couple of things: -
> 
> Using fork: -
> http://www.php.net/manual/en/function.pcntl-fork.php
> 
> This doesn't work on my windows installation and i'm not sure it will be
> enabled on my hosting.
> 
> Using a headers hack method:-
> 
> http://www.brandonchecketts.com/archives/performing-post-output-script-processing-in-php
> 
> This seems to work the first time, but not the next time you call it.
> 
> Register Shutdown function
> http://uk2.php.net/register_shutdown_function
> 
> This doesn't work at all - it just blocks until the "other processing" is
> finished.
> 
> Is there anything that works with the Zend Framework? Any other ideas?

>From the above experiments you've tried, it sounds like you want to
offload some processing to occur after the content is delivered, but
want it to occur without keeping the connection to the client. With this
in mind, I'd suggest building a job queue. With this sort of solution,
you send a message to the queue, and then a queue processor queries it
periodically and performs routines pertinent to the message sent.

There is a Zend_Queue proposal under review, but not yet accepted. There
are also commercial solutions such as Zend Platform's Job Queue which
can perform this work. 

You can also roll your own, something I've done before myself. Usually,
you provide a callback, and the arguments for the callback, and your
queue processor then does the processing. I've done implementations that
used static class methods for the callbacks, as well as some that would
instantiate the given class and then call the given method with the
provided arguments (utilizing call_user_func_array()).

-- 
Matthew Weier O'Phinney
Software Architect   | matt...@zend.com
Zend Framework   | http://framework.zend.com/


Re: [fw-general] Continue Processing after an action is completed

2009-02-08 Thread Ashley McConnell



keith Pope-4 wrote:
> 
> The thing that springs to mind is using the postDispatch on either the
> Front Controller or the Action Controller
> 
> 

Hi Keith,

Thanks for the reply - I did try that actually, but it seems to run before
the connection to the client is closed.  I tried a sleep(5) in there and the
page took around 5 seconds to fully load, whereas without the postDispatch
it was almost instant.

All the best,
Ash

-- 
View this message in context: 
http://www.nabble.com/Continue-Processing-after-an-action-is-completed-tp21900147p21900748.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Continue Processing after an action is completed

2009-02-08 Thread keith Pope
The thing that springs to mind is using the postDispatch on either the
Front Controller or the Action Controller

2009/2/8 Ashley McConnell :
>
> Hi Folks,
>
> I would like to be able to call an action / respond to the client and then
> continue on with some further processing.
>
> I have tried a couple of things: -
>
> Using fork: -
> http://www.php.net/manual/en/function.pcntl-fork.php
>
> This doesn't work on my windows installation and i'm not sure it will be
> enabled on my hosting.
>
> Using a headers hack method:-
>
> http://www.brandonchecketts.com/archives/performing-post-output-script-processing-in-php
>
> This seems to work the first time, but not the next time you call it.
>
> Register Shutdown function
> http://uk2.php.net/register_shutdown_function
>
> This doesn't work at all - it just blocks until the "other processing" is
> finished.
>
> Is there anything that works with the Zend Framework? Any other ideas?
>
> Thanks for your help
> All the best,
> Ash
>
> --
> View this message in context: 
> http://www.nabble.com/Continue-Processing-after-an-action-is-completed-tp21900147p21900147.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>



-- 
--
[MuTe]
--


[fw-general] Continue Processing after an action is completed

2009-02-08 Thread Ashley McConnell

Hi Folks,

I would like to be able to call an action / respond to the client and then
continue on with some further processing.

I have tried a couple of things: -

Using fork: -
http://www.php.net/manual/en/function.pcntl-fork.php

This doesn't work on my windows installation and i'm not sure it will be
enabled on my hosting.

Using a headers hack method:-

http://www.brandonchecketts.com/archives/performing-post-output-script-processing-in-php

This seems to work the first time, but not the next time you call it.

Register Shutdown function
http://uk2.php.net/register_shutdown_function

This doesn't work at all - it just blocks until the "other processing" is
finished.

Is there anything that works with the Zend Framework? Any other ideas?

Thanks for your help
All the best,
Ash

-- 
View this message in context: 
http://www.nabble.com/Continue-Processing-after-an-action-is-completed-tp21900147p21900147.html
Sent from the Zend Framework mailing list archive at Nabble.com.