Skip to content

Commit c67d14e

Browse files
author
sioomy
committed
supervisor
1 parent 455f582 commit c67d14e

8 files changed

Lines changed: 147 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
## 协程原理
2222

23-
![avatar](/tutorial/coroutine.jpg)
23+
![avatar](/tutorial/pic/coroutine.jpg)
2424

2525
协程本质是异步非阻塞IO的实现方式之一。php-fpm要想实现协程,需要分成两部分,一部分是调度器,另外一部分就是在PHP扩展中实现协程逻辑。
2626

@@ -226,7 +226,7 @@ Note: this item has not been completely tested. Please be careful not to use it
226226

227227
## Coroutine theory
228228

229-
![avatar](/tutorial/coroutine.jpg)
229+
![avatar](/tutorial/pic/coroutine.jpg)
230230

231231
The essence of the Coroutine is one of the asynchronous non blocking IO implementations. If php-fpm wants to implement the syndication, it needs to be divided into two parts, one is the scheduler, the other is to implement the syndication logic in the PHP extension.
232232

tutorial/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ RUN yum -y install python-devel
1212
RUN yum -y install openssl
1313
RUN yum -y install openssl-devel
1414
RUN yum -y install wget
15+
RUN cd /data/soft/ && wget https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-7.noarch.rpm
16+
RUN cd /data/soft/ && rpm -ivh epel-release-latest-7.noarch.rpm
17+
RUN yum -y install supervisor
1518

1619
RUN cd /data/soft/ && git clone https://github.com/sioomy/php-fpm-coroutine.git
1720
RUN cd /data/soft/ && git clone https://github.com/libevent/libevent.git
@@ -24,11 +27,10 @@ RUN cd /data/soft/libxml2 && sh autogen.sh && ./configure && make && make instal
2427
RUN cd /data/soft/php-fpm-coroutine && sh buildconf --force && ./configure --prefix=/usr/local/php7 --enable-fpm --enable-coro_http --with-openssl --enable-maintainer-zts && make && make install
2528
RUN cd /data/soft/nginx-1.14.0 && ./configure && make && make install
2629

27-
ADD ./nginx.conf /usr/local/nginx/conf/
28-
ADD ./www.conf /usr/local/php7/etc/php-fpm.d/
29-
ADD ./php-fpm.conf /usr/local/php7/etc/
30-
ADD ./php.ini /usr/local/php7/lib/
30+
ADD ./conf/nginx.conf /usr/local/nginx/conf/
31+
ADD ./conf/www.conf /usr/local/php7/etc/php-fpm.d/
32+
ADD ./conf/php-fpm.conf /usr/local/php7/etc/
33+
ADD ./conf/php.ini /usr/local/php7/lib/
34+
ADD ./conf/supervisord.conf /etc/supervisord.conf
3135

32-
33-
RUN /usr/local/php7/sbin/php-fpm
34-
CMD ["/usr/local/nginx/sbin/nginx"]
36+
CMD ["/usr/bin/supervisord"]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979
; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
8080
; Default Value: yes
81-
daemonize = yes
81+
daemonize = no
8282

8383
; Set open file descriptor rlimit for the master process.
8484
; Default Value: system defined value
File renamed without changes.

tutorial/conf/supervisord.conf

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
; Sample supervisor config file.
2+
3+
[unix_http_server]
4+
file=/var/run/supervisor/supervisor.sock ; (the path to the socket file)
5+
chmod=0700 ; sockef file mode (default 0700)
6+
;chown=nobody:nogroup ; socket file uid:gid owner
7+
;username=user ; (default is no username (open server))
8+
;password=123 ; (default is no password (open server))
9+
10+
;[inet_http_server] ; inet (TCP) server disabled by default
11+
;port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface)
12+
;username=user ; (default is no username (open server))
13+
;password=123 ; (default is no password (open server))
14+
15+
[supervisord]
16+
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
17+
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
18+
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
19+
loglevel=info ; (log level;default info; others: debug,warn,trace)
20+
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
21+
nodaemon=true ; (start in foreground if true;default false)
22+
minfds=1024 ; (min. avail startup file descriptors;default 1024)
23+
minprocs=200 ; (min. avail process descriptors;default 200)
24+
;umask=022 ; (process file creation umask;default 022)
25+
;user=chrism ; (default is current user, required if root)
26+
;identifier=supervisor ; (supervisord identifier, default is 'supervisor')
27+
;directory=/tmp ; (default is not to cd during start)
28+
;nocleanup=true ; (don't clean up tempfiles at start;default false)
29+
;childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP)
30+
;environment=KEY=value ; (key value pairs to add to environment)
31+
;strip_ansi=false ; (strip ansi escape codes in logs; def. false)
32+
33+
; the below section must remain in the config file for RPC
34+
; (supervisorctl/web interface) to work, additional interfaces may be
35+
; added by defining them in separate rpcinterface: sections
36+
[rpcinterface:supervisor]
37+
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
38+
39+
[supervisorctl]
40+
serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL for a unix socket
41+
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
42+
;username=chris ; should be same as http_username if set
43+
;password=123 ; should be same as http_password if set
44+
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
45+
;history_file=~/.sc_history ; use readline history if available
46+
47+
; The below sample program section shows all possible program subsection values,
48+
; create one or more 'real' program: sections to be able to control them under
49+
; supervisor.
50+
51+
;[program:theprogramname]
52+
;command=/bin/cat ; the program (relative uses PATH, can take args)
53+
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
54+
;numprocs=1 ; number of processes copies to start (def 1)
55+
;directory=/tmp ; directory to cwd to before exec (def no cwd)
56+
;umask=022 ; umask for process (default None)
57+
;priority=999 ; the relative start priority (default 999)
58+
;autostart=true ; start at supervisord start (default: true)
59+
;autorestart=true ; retstart at unexpected quit (default: true)
60+
;startsecs=10 ; number of secs prog must stay running (def. 1)
61+
;startretries=3 ; max # of serial start failures (default 3)
62+
;exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
63+
;stopsignal=QUIT ; signal used to kill process (default TERM)
64+
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
65+
;user=chrism ; setuid to this UNIX account to run the program
66+
;redirect_stderr=true ; redirect proc stderr to stdout (default false)
67+
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
68+
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
69+
;stdout_logfile_backups=10 ; # of stdout logfile backups (default 10)
70+
;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
71+
;stdout_events_enabled=false ; emit events on stdout writes (default false)
72+
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
73+
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
74+
;stderr_logfile_backups=10 ; # of stderr logfile backups (default 10)
75+
;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
76+
;stderr_events_enabled=false ; emit events on stderr writes (default false)
77+
;environment=A=1,B=2 ; process environment additions (def no adds)
78+
;serverurl=AUTO ; override serverurl computation (childutils)
79+
80+
; The below sample eventlistener section shows all possible
81+
; eventlistener subsection values, create one or more 'real'
82+
; eventlistener: sections to be able to handle event notifications
83+
; sent by supervisor.
84+
85+
;[eventlistener:theeventlistenername]
86+
;command=/bin/eventlistener ; the program (relative uses PATH, can take args)
87+
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
88+
;numprocs=1 ; number of processes copies to start (def 1)
89+
;events=EVENT ; event notif. types to subscribe to (req'd)
90+
;buffer_size=10 ; event buffer queue size (default 10)
91+
;directory=/tmp ; directory to cwd to before exec (def no cwd)
92+
;umask=022 ; umask for process (default None)
93+
;priority=-1 ; the relative start priority (default -1)
94+
;autostart=true ; start at supervisord start (default: true)
95+
;autorestart=unexpected ; restart at unexpected quit (default: unexpected)
96+
;startsecs=10 ; number of secs prog must stay running (def. 1)
97+
;startretries=3 ; max # of serial start failures (default 3)
98+
;exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
99+
;stopsignal=QUIT ; signal used to kill process (default TERM)
100+
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
101+
;user=chrism ; setuid to this UNIX account to run the program
102+
;redirect_stderr=true ; redirect proc stderr to stdout (default false)
103+
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
104+
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
105+
;stdout_logfile_backups=10 ; # of stdout logfile backups (default 10)
106+
;stdout_events_enabled=false ; emit events on stdout writes (default false)
107+
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
108+
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
109+
;stderr_logfile_backups ; # of stderr logfile backups (default 10)
110+
;stderr_events_enabled=false ; emit events on stderr writes (default false)
111+
;environment=A=1,B=2 ; process environment additions
112+
;serverurl=AUTO ; override serverurl computation (childutils)
113+
114+
; The below sample group section shows all possible group values,
115+
; create one or more 'real' group: sections to create "heterogeneous"
116+
; process groups.
117+
118+
;[group:thegroupname]
119+
;programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions
120+
;priority=999 ; the relative start priority (default 999)
121+
122+
; The [include] section can just contain the "files" setting. This
123+
; setting can list multiple files (separated by whitespace or
124+
; newlines). It can also contain wildcards. The filenames are
125+
; interpreted as relative to this file. Included files *cannot*
126+
; include files themselves.
127+
128+
;[include]
129+
;files = supervisord.d/*.ini
130+
[supervisord]
131+
nodaemon=true
132+
[program:php-fpm]
133+
command=/usr/local/php7/sbin/php-fpm
134+
[program:nginx]
135+
command=/usr/local/nginx/sbin/nginx

0 commit comments

Comments
 (0)