I
I
Ilya Plotnikov2011-08-16 21:14:04
PHP
Ilya Plotnikov, 2011-08-16 21:14:04

What is the way to implement forks in PHP?

Here I want to write the demon working in several flows. fork is unstable, exec somehow from "childhood" inspires the idea of ​​​​a huge security hole. Maybe there are normal ways?
Is gearman good for flow control?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
s3ek, 2011-08-16
@ilyaplot

Fork is which pcntl_fork? I implemented it somehow with the help of its multithreading, no problems were noticed.

C
cat_crash, 2011-08-16
@cat_crash

Had the same goal. I recommend reading: habrahabr.ru/blogs/php/40432/

A
Alexey Ashurok, 2011-08-17
@AotD

fork from pcntl_fork is just as unstable as a normal Cish fork. No more, no less.
In child processes, we control the fall on any error, including an interpreter error, and correctly terminate the process with a return code.
We analyze the return code in the parent process to determine whether the hamster died of natural causes or was torn from a drop of nicotine.
You can use the mind of your predecessors and use ready-made solutions: phpdaemon.net/
With proper skill and no fear of rebuilding php, this thing will not only prefork the required number of workers, but also do hot code replacement right at runtime.
Or nanoserv.si.kz/ - a little easier, clearer for starters, but for 70% of tasks it will be enough

S
sandrain, 2013-11-22
@sandrain

Is gearman good for flow control?

There were no problems, everyone is happy so far.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question