xxfpm进程管理器制服php-cgi奔溃退出+结合RunHiddenConsole的使用来

经测试,支持Win32和Linux-x86平台。对于用php的人,有了这个东西来维护一定数量的进程,就能制服经常崩溃退出的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

使用例子:

xxfpm z:/php5/php-cgi.exe -n 5 -p 8080


有人问,如何给程序加入参数?这个不难,使用双引号即可,路径要用”/”而不用”\”。例如要指定php.ini的路径,可以用下面例子:

xxfpm “z:/php5/php-cgi.exe -c z:/php5/php.ini” -n 5 -i 127.0.0.1 -p 8080

 

结合RunHiddenConsole的使用方法:

C:\soft\RunHiddenConsole.exe xxfpm "c:\php\Php-5.2.17-ts-03\php-cgi.exe -c  C:\php\Php-5.2.17-ts-03\php.ini" -n 5 -i 127.0.0.1 -p 9000


如何维护进程:


Windows上使用CreateProcess创建进程,使用WaitForSingleObject等待进程结束;Linux上使用fork和execl创建进程,使用waitpid等待进程结束。Linux的版本多了在创建子进程的时候可以设置进程限制,能够以受限用户方式来运行。


当进程管理器被关闭的时候,它所创建的所有子进程也必须被关闭。Windows上使用JobObject这个东西来把子进程与管理器的进程产生关联,感谢iceboy提供的资料!Linux上通过捕捉关闭信号,然后给所有子进程发送SIGTERM来结束子进程。详见源代码!!!


就是怎么简单!我发现好多文章教程写的都很不错,但是最后结果都不附上文章中使用的工具下载地址,去百度找又很麻烦导致无法更好的学习! 下面附上工具下载地址


GitHub地址:

https://github.com/78/xxfpm


xxfpm:

http://www.ebbbe.com/wp-content/uploads/2016/01/xxfpm-master.zip


RunHiddenConsole:

http://www.ebbbe.com/wp-content/uploads/2016/01/RunHiddenConsole.zip


你可能感兴趣的:(自动关闭,xxfpm,xfpm使用方法,php-cgi奔溃)