PHPDaemon development-use QPM to manage PID files

Source: Internet
Author: User
: This article mainly introduces PHPDaemon development-using QPM to manage PID files. For more information about PHP tutorials, see. 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 send signals to the process. Pidfile in QPM is the module used to manage PID files.

Example:

# Pid_main.php Start (); while (true) sleep (10);?> Run 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. Run php pid_main.php again, and the script reports an error, prompting that the process already exists. Fatal error: Uncaught exception 'qpm \ pidfile \ exception' with message' process exists, no need to start a new one 'in.../qpm/pidfile/Manager. php: 41

In addition, qpm \ pid \ Manager has the getProcess method.

# Pid_check.php GetProcess ()-> getPid ();?> If the pid file does not exist or is empty, an exception is thrown. Note: the object obtained by The getProcess method is not 100% the original process. The detection here will be improved in later versions.

The above introduces PHP Daemon development-using QPM to manage PID files, including some content, and hope to be helpful to friends who are interested in PHP tutorials.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.