Skip to content

Commit

Permalink
Add explanation how to make the Process survive a response
Browse files Browse the repository at this point in the history
Fixes #7151

It confuses user that could be tempted to use the Asynchronous Process feature to achieve long running task after the Response is sent.

The result is the following :
from no code execution (if you send a Response really fast)
to partial code execution
  • Loading branch information
tristanbes committed Nov 22, 2016
1 parent ed3ae3c commit 64de236
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ are done doing other stuff::
which means that your code will halt at this line until the external
process is completed.

.. note::
If a `Response` is sent **before** what `Process` is running had a chance to complete,
the server process will be killed (depending on your OS). It means that your task
will be stopped right away.
Running an asynchronous process is not the same than running a processing surviving yourselves.

If you want your process to survive the request/response cycle, you could take
advantage of the `kernel.terminate` event, and run your command **synchronuously**
inside this event. Be aware that `kernel.terminate` is called only if you run `PHP-FPM`.

:method:`Symfony\\Component\\Process\\Process::wait` takes one optional argument:
a callback that is called repeatedly whilst the process is still running, passing
in the output and its type::
Expand Down

0 comments on commit 64de236

Please sign in to comment.