当前位置:网站首页>How to stop PHP FPM service in php7
How to stop PHP FPM service in php7
2022-06-13 07:08:00 【guangsu.】
php7 How to stop php-fpm service
stay PHP All stages of the life cycle , Some service related operations are performed through SAPI Interface implementation .
Each server abstraction layer follows the same Convention , Here we call it SAPI Interface .
stay PHP In the source code , When you need to call server related information , All pass SAPI The corresponding method call implementation in the interface
php-fpm + nginx
php + terminal
...
PHP Four common operation modes
SAPI(Server Application Programming Interface) Server application programming interface , namely PHP Interface with other applications .
Every SAPI Implementation is a _sapi_module_struct Structural variable .
PHP There are many ways to execute a script , adopt Web The server , Or directly on the command line , It can also be embedded in other programs .SAPI It provides an interface for external communication , common SAPI Yes :cgi、fast-cgi、cli、isapi apache Modular DLL
ISAPIPattern (eg Apache : apache2handler mode ) With web A module of the server is loaded and running , It's really just the PHP Source code and webServer Compile together with the code of , The runtime is the same process , Share the same address space . for example LAMP in ,PHP It's doing Apache A module of .Apache Is a multithreaded call php Modular .(same as IIS)CGIPatternfork-and-executewebServer Forward dynamic requests to CGI Program ( With php As an example ), Equivalent to fork A subprocess , thenexec(php process), use CGI Program to interpret the request content , Finally, the subprocess'soutputreturn . here webServer And php The address space of the process is independent . At this time php Is to run as a separate program .FastCGIPattern This form is CGI Enhanced version of ,CGI It's a single process , Multithreaded running mode , The program will be destroyed after execution , So you need to load configuration and environment variables every time ( establish - perform ).
and FastCGI Is different ,FastCGI Is a resident (long-live) Type CGI, It can be executed all the time , Once activated , It doesn't take time to fork once .CLIcommand line interface
CLI
php_module_startup
php_request_startup
php_execute_script
php_request_shutdown
php_module_shutdown
PHP-FPM
php 5.3.3 After the php-fpm No longer supported php-fpm (start|stop|reload) Wait for the order , You need to use signal control .php-fpm master Processes can understand the following signals
kill -USR1 "php-fpm master pid"Reopen the log file . After execution You'll find thatphp-fpm master/workerprocessidnot changekill -USR2 "php-fpm master pid"Smooth reload allphp-fpmprocess , After execution, you will findphp-fpm master/workerprocessidhave changed.kill -KILL/-9 php-fpm-master.pid, Force to kill master process , This signal is not allowed to be interrupted / Blocking , here master The process could not notify the recycle worker process , So at this timeworkerThe process is still listening port, It can still be handled normally http request .kill -INT/-QUIT/-TERM master pid,stop php-fpm serviceThe signal is received by the current process tree . in other words , Not only will the current process receive a signal , Its child processes will also receive .kill master pidsend outSIGTERMSignal to process The signal may be blocked ,masterRecyclableworkerprocess .
example.
[[email protected] ~]$>ps aux | grep php-fpm
root 17000 0.0 0.0 243220 7208 ? Ss 17:00 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
sujianh+ 17001 0.0 0.0 245304 7072 ? S 17:00 0:00 php-fpm: pool www
sujianh+ 17002 0.0 0.0 245304 7072 ? S 17:00 0:00 php-fpm: pool www
sujianh+ 17069 0.0 0.0 112816 976 pts/3 S+ 17:01 0:00 grep --color=auto php-fpm
[[email protected] ~]$>sudo kill -USR1 17000
[[email protected] ~]$>ps aux | grep php-fpm
root 17000 0.0 0.0 243220 7208 ? Ss 17:00 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
sujianh+ 17001 0.0 0.0 245304 7072 ? S 17:00 0:00 php-fpm: pool www
sujianh+ 17002 0.0 0.0 245304 7072 ? S 17:00 0:00 php-fpm: pool www
sujianh+ 17105 0.0 0.0 112816 972 pts/3 S+ 17:01 0:00 grep --color=auto php-fpm
[[email protected] ~]$>sudo kill -USR2 17000
[[email protected] ~]$>ps aux | grep php-fpm
root 17122 0.0 0.0 243220 7212 ? Ss 17:01 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
sujianh+ 17123 0.0 0.0 245304 7072 ? S 17:01 0:00 php-fpm: pool www
sujianh+ 17124 0.0 0.0 245304 7072 ? S 17:01 0:00 php-fpm: pool www
sujianh+ 17126 0.0 0.0 112816 976 pts/3 S+ 17:01 0:00 grep --color=auto php-fpm
[[email protected] ~]$>pstree 17122 -a
php-fpm
├─php-fpm
└─php-fpm
[[email protected] ~]$>sudo kill -INT 17122
[[email protected]v529 ~]$>ps aux | grep php-fpm
sujianh+ 17229 0.0 0.0 112816 976 pts/3 S+ 17:03 0:00 grep --color=auto php-fpm
so we should use sudo kill -INT master.pid to kill php-fpm service.
nginx Of master-worker Mechanism and fpm Basically the same . But there is a problem that needs attention , Use systemctl Started up master By kill in the future ,worker And I'll die .
Normal start nginx,kill fall master
[[email protected] sbin]$>which nginx
/usr/sbin/nginx
[[email protected] sbin]$>sudo nginx
[[email protected] sbin]$>ps aux | grep nginx
root 4562 0.0 0.0 46608 1084 ? Ss 21:46 0:00 nginx: master process nginx
sujianh+ 4563 0.0 0.0 49128 2088 ? S 21:46 0:00 nginx: worker process
sujianh+ 4578 0.0 0.0 112812 972 pts/0 S+ 21:46 0:00 grep --color=auto nginx
[[email protected] sbin]$>sudo kill -9 4562
[[email protected] sbin]$>ps aux | grep nginx
sujianh+ 4563 0.0 0.0 49128 2088 ? S 21:46 0:00 nginx: worker process
sujianh+ 4612 0.0 0.0 112812 972 pts/0 S+ 21:46 0:00 grep --color=auto nginx
[[email protected] sbin]$>kill -9 4563
[[email protected] sbin]$>ps aux | grep nginx
sujianh+ 4638 0.0 0.0 112812 972 pts/0 S+ 21:47 0:00 grep --color=auto nginx
Use systemctl Starting up master By kill After falling ,worker Will also be killed
[[email protected] sbin]$>systemctl start nginx
[[email protected] sbin]$>ps aux | grep nginx
root 4678 0.0 0.0 46608 1072 ? Ss 21:47 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
sujianh+ 4679 0.0 0.0 49124 2080 ? S 21:47 0:00 nginx: worker process
sujianh+ 4702 0.0 0.0 112812 972 pts/0 S+ 21:47 0:00 grep --color=auto nginx
[[email protected] sbin]$>sudo kill -9 4678
[[email protected] sbin]$>ps aux | grep nginx
sujianh+ 4732 0.0 0.0 112812 972 pts/0 S+ 21:47 0:00 grep --color=auto nginx
rective run
[[email protected] ~]$>kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3
38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX
[[email protected] ~]$>sudo nginx
[sudo] password for sujianhui:
[[email protected] ~]$>ps aux | grep nginx
root 3628 0.0 0.0 46600 1052 ? Ss 09:49 0:00 nginx: master process nginx
sujianh+ 3629 0.0 0.0 49096 2056 ? S 09:49 0:00 nginx: worker process
sujianh+ 3637 0.0 0.0 112812 972 pts/0 S+ 09:49 0:00 grep --color=auto nginx
[[email protected] ~]$>sudo kill -SIGTERM 3628
[[email protected] ~]$>ps aux | grep nginx
sujianh+ 3744 0.0 0.0 112812 972 pts/0 S+ 09:50 0:00 grep --color=auto nginx
[[email protected] ~]$>sudo nginx
[[email protected] ~]$>ps aux | grep nginx
root 3766 0.0 0.0 46600 1052 ? Ss 09:51 0:00 nginx: master process nginx
sujianh+ 3767 0.0 0.0 49096 2056 ? S 09:51 0:00 nginx: worker process
sujianh+ 3775 0.0 0.0 112812 972 pts/0 S+ 09:51 0:00 grep --color=auto nginx
[[email protected] ~]$>sudo kill -9 3766
[[email protected] ~]$>ps aux | grep nginx
sujianh+ 3767 0.0 0.0 49096 2056 ? S 09:51 0:00 nginx: worker process
sujianh+ 3799 0.0 0.0 112812 972 pts/0 S+ 09:51 0:00 grep --color=auto nginx
apache prefork
边栏推荐
- Periodontitis investigation (ongoing)
- C # related knowledge points
- [turn to] FPGA interview questions
- C # Advanced Programming - Feature Section
- [Markov chain Monte Carlo] Markov chain Monte Carlo method sampling prior distribution
- Ansible PlayBook的中清单变量优先级分析及清单变量如何分离总结
- 汇编语言基础:寄存器和寻址方式
- 考研英语
- Differences between SQL and NoSQL of mongodb series
- Yolov5 analysis | parameters and performance indicators
猜你喜欢

髋关节MR详细图谱(转载)

Tidb statistics

Tidb data migration (DM) Introduction

SDN基本概述

SDN basic overview

Tidb index optimization

Implementation of fruit mall wholesale platform based on SSM

Chain 2+1 reward, what kind of mode is beautiful everyday seconds?

Will the chain 2+1 model be a new business outlet and a popular Internet e-commerce market?

Problems encountered during commissioning of C # project
随机推荐
RT thread simulator lvgl control: button button style
【騰訊阿裏最全面試題集錦】(四面:3輪技術+1輪HR)
RT-Thread 模拟器 simulator LVGL控件:slider 控件
【ViveFocus使用WaveVR插件获取手柄操作事件】
Upper computer development (code debugging of firmware download software)
Will the chain 2+1 model be a new business outlet and a popular Internet e-commerce market?
Tidb data migration (DM) Introduction
Upper computer development (software test of firmware download software)
Network planning common interview knowledge (I)
Byte (nine)
快速排序
C # using multithreading
个人js学习笔记
杭州网上开户是安全的吗?
Postgraduate entrance examination English
Problems encountered during commissioning of C # project
FSM状态机
Is it safe for Hangzhou Securities to open an account?
面试必刷算法TOP101之单调栈 TOP31
AIO Introduction (VIII)