Home > Backend Development > PHP Tutorial > Swoole multi-process problem about the unexpected exit of the main process

Swoole multi-process problem about the unexpected exit of the main process

WBOY
Release: 2016-10-11 14:23:10
Original
1528 people have browsed it

My brother is currently working on a multi-process crawling service. It is now a main process and 10 child processes. If the child process exits unexpectedly, create another child process.

But this way, if the main process accidentally exits the child process, it will not exit with it. Next time I open this service, I will create 10 child processes, which adds up to 20 child processes. Not only will the data in redis be messed up, but it will also take up a lot of memory. Is there anything wrong? What is a good way to ensure that if the main process ends unexpectedly, the following child processes will be shut down together? ?

My idea is that every time the main process is started, exec executes the next shell script. The shell script closes all related processes except this main process. I wonder if you guys have any advice?

Reply content:

My brother is currently working on a multi-process crawling service. It is now a main process and 10 child processes. If the child process exits unexpectedly, create another child process.

But this way, if the main process accidentally exits the child process, it will not exit with it. Next time I open this service, I will create 10 child processes, which adds up to 20 child processes. Not only will the data in redis be messed up, but it will also take up a lot of memory. Is there anything wrong? What is a good way to ensure that if the main process ends unexpectedly, the following child processes will be shut down together? ?

My idea is that every time the main process is started, exec executes the next shell script. The shell script closes all related processes except this main process. I wonder if you guys have any advice?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template