4
nitwhiz
1y

I challenge you to start a process from php.

The following criteria must be fulfilled:

- php-fpm
- the process is started on http request by user
- the response does not wait for the process to be finished
- the process must finish, possibly after the response reached the user
- the running process does not block a fpm thread/worker from handling further requests

Simple, right?

Comments
  • 0
    @ostream interesting. exec, popen, new Process, didn't read about shell_exec.

    This language is bullshit.

    exec with & didn't work for me, why would shell_exec? The response was blocked until the process finished.
  • 1
    Try a message queue. Build a backend consumer to do the thing async.
  • 2
    @lungdart yes of course. But I didn't ask for the right way.
  • 3
    @nitwhiz i don't think there's going to be a way to do it.

    You want the parent process of a fork to return and exit, and the child to keep working. I'm not sure if that's possible. The parent process must wait for the child to exit before it can.
  • 1
    @lungdart I learned that the hard way today. ^^
  • 0
    Just saying: this has nothing to do with PHP.

    Whenever devs start fiddling around with stuff like process handling, shared memory, semaphore locking etc ...

    PHP isn't the right language.

    Neither is NodeJS or similar web backend language.

    You *can* do it in PHP.

    But it will be a painful, limited and errorprone solution.

    Like others said: You're looking for sth like a job server / queue system etc.
  • 1
    @IntrusionCM bro i know. :D

    This is a rant, not a support ticket.
  • 1
    @nitwhiz

    Sorry, it read like a support ticket.

    :)
Add Comment