Windows uses XXFPM to resolve php-cgi process shutdown automatically

Source: Internet
Author: User

The Windows php-cgi process automatically shuts down after processing a certain number of accesses, and since there is no way to directly allow the php-cgi process to support more access, it is only possible to start multiple processes to meet the requirements.

XXFPM is an executable program that can start multiple php-cgi processes at the same time, and when any one process shuts down, it restarts a new process, always maintaining a certain number of processes, so that there is no need to create manually, saving a lot of trouble.

XXFPM need PthreadGC2.dll support, if not, will be an error. You can start xxfpm by placing the PthreadGC2.dll in the xxfpm bin directory.

XXFPM Detailed Introduction

Tested to support WIN32 and linux-x86 platforms. For people with PHP, with this thing to maintain a certain number of processes, you can subdue the frequent collapse of the exit PHP-CGI!!!

USAGE:XXFPM Path [-N number] [-I IP] [-p port]
Manage FastCGI processes.

-N,--number number of processes to keep
-I,--IP IP address to bind
-P,--port port to bind, default is 8000
-U,--user start processes using specified Linux user
-G,--group start processes using specified Linux group
-R,--root change root direcotry for the processes
-h,--help output usage information and exit
-V,--version output version information and exit

The first to write a more standard terminal application, I looked at the cygwin of some of the source code, and then learned how to use Getopt, is written relatively standard, but the code is not short.

Examples of Use:
XXFPM z:/php5/php-cgi.exe-n 5-p 8080

Someone asked, how to add parameters to the program? This is not difficult, use double quotes, the path to use "/" instead of "\". For example, to specify the path to the php.ini, use the following example:
XXFPM "Z:/php5/php-cgi.exe-c Z:/php5/php.ini"-N 5-i 127.0.0.1-p 8080

How to maintain a process:

Use CreateProcess to create processes on Windows, use WaitForSingleObject to wait for processes to end, use fork and execl to create processes on Linux, and use Waitpid to wait for processes to end. There are many versions of Linux. Process limits can be set when creating sub-processes and can be run in a limited user mode.

When the process manager is closed, all the child processes it creates must also be closed. Jobobject is used on Windows to correlate the process with the manager, thanks to Iceboy for the information! Linux turns off the signal by snapping and then sends Sigterm to all child processes to end the subprocess. See Source Code!!!

Windows uses XXFPM to resolve php-cgi process shutdown automatically

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.