PHP Daemon Development-Use QPM to manage PID files

WBOY
Release: 2016-08-08 09:29:16
Original
1147 people have browsed it
When writing a Daemon program, we can use a PID file to mark whether the process has been created to prevent the process from being started repeatedly. The PID file also records the process number to facilitate sending signals to the process. The pidfile in QPM is the module used to manage PID files. Example: #pid_main.php start(); while(true) sleep(10); ?> When executing php pid_main.php for the first time, we can see that the pid_main.php.pid file is generated and the process continues to run. Execute php pid_main.php again, and the script reports an error, indicating that the process already exists. Fatal error: Uncaught exception 'qpmpidfileException' with message 'process exists, no need to start a new one' in .../qpm/pidfile/Manager.php:41In addition, qpmpidManager also has a getProcess method. #pid_check.php getProcess()->getPid(); ?> If the pid file does not exist or is empty, an exception will be thrown. Note: The object obtained by the getProcess method is not 100% guaranteed to be the original process. Subsequent versions will improve the detection here.

The above has introduced PHP Daemon development - using QPM to manage PID files, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!