como faço para iniciar o php7.0-fpm com o supervisord?

1

Eu estou tentando construir um 16.04lts ubuntu dockerized com apache2 e nginx com php7.0-fpm

comandos que usei mas não funcionaram

[program:php-fpm7.0]
command = /usr/sbin/php-fpm7.0 --daemonize --fpm-config /etc/php/7.0/fpm/php-fpm.conf
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

e

[program:php-fpm7.0]
command = /usr/sbin/php-fpm7.0 -c /etc/php/7.0/fpm/php-fpm.conf
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

e

[program:php-fpm7.0]
command = /usr/sbin/php-fpm7.0 -c /etc/php/7.0/fpm
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

abaixo estão os logs de erro da janela de encaixe quando tento executar como contêineres

do contêiner apache2

2016-06-26 20:04:21,488 CRIT Set uid to user 0
2016-06-26 20:04:21,496 INFO RPC interface 'supervisor' initialized
2016-06-26 20:04:21,496 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2016-06-26 20:04:21,496 INFO supervisord started with pid 8
2016-06-26 20:04:22,499 INFO spawned: 'php-fpm7.0' with pid 11
2016-06-26 20:04:22,500 INFO spawned: 'apache2' with pid 12
2016-06-26 20:04:22,571 INFO exited: apache2 (exit status 0; not expected)
[26-Jun-2016 20:04:22] ERROR: Unable to create the PID file (/run/php/php7.0-fpm.pid).: No such file or directory (2)
[26-Jun-2016 20:04:22] ERROR: FPM initialization failed
2016-06-26 20:04:22,609 INFO exited: php-fpm7.0 (exit status 78; not expected)
2016-06-26 20:04:23,611 INFO spawned: 'php-fpm7.0' with pid 74
2016-06-26 20:04:23,613 INFO spawned: 'apache2' with pid 75
httpd (pid 16) already running
2016-06-26 20:04:23,669 INFO exited: apache2 (exit status 0; not expected)
[26-Jun-2016 20:04:23] ERROR: Unable to create the PID file (/run/php/php7.0-fpm.pid).: No such file or directory (2)
[26-Jun-2016 20:04:23] ERROR: FPM initialization failed
2016-06-26 20:04:23,694 INFO exited: php-fpm7.0 (exit status 78; not expected)
2016-06-26 20:04:25,698 INFO spawned: 'php-fpm7.0' with pid 79
2016-06-26 20:04:25,700 INFO spawned: 'apache2' with pid 80
httpd (pid 16) already running
2016-06-26 20:04:25,758 INFO exited: apache2 (exit status 0; not expected)
[26-Jun-2016 20:04:25] ERROR: Unable to create the PID file (/run/php/php7.0-fpm.pid).: No such file or directory (2)
[26-Jun-2016 20:04:25] ERROR: FPM initialization failed
2016-06-26 20:04:25,784 INFO exited: php-fpm7.0 (exit status 78; not expected)
2016-06-26 20:04:28,788 INFO spawned: 'php-fpm7.0' with pid 84
2016-06-26 20:04:28,789 INFO spawned: 'apache2' with pid 85
httpd (pid 16) already running
2016-06-26 20:04:28,847 INFO exited: apache2 (exit status 0; not expected)
2016-06-26 20:04:28,857 INFO gave up: apache2 entered FATAL state, too many start retries too quickly
[26-Jun-2016 20:04:28] ERROR: Unable to create the PID file (/run/php/php7.0-fpm.pid).: No such file or directory (2)
[26-Jun-2016 20:04:28] ERROR: FPM initialization failed
2016-06-26 20:04:28,872 INFO exited: php-fpm7.0 (exit status 78; not expected)
2016-06-26 20:04:29,873 INFO gave up: php-fpm7.0 entered FATAL state, too many start retries too quickly

e

do container nginx

2016-06-26 11:19:02,307 CRIT Set uid to user 0
2016-06-26 11:19:02,320 INFO RPC interface 'supervisor' initialized
2016-06-26 11:19:02,320 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2016-06-26 11:19:02,321 INFO supervisord started with pid 14
2016-06-26 11:19:03,323 INFO spawned: 'php7.0-fpm' with pid 17
2016-06-26 11:19:03,324 INFO spawned: 'nginx' with pid 18
[26-Jun-2016 11:19:03] ERROR: unable to bind listening socket for address '/run/php/php7.0-fpm.sock': No such file or directory (2)
[26-Jun-2016 11:19:03] ERROR: FPM initialization failed
2016-06-26 11:19:03,406 INFO exited: php7.0-fpm (exit status 78; not expected)
2016-06-26 11:19:04,409 INFO spawned: 'php7.0-fpm' with pid 20
2016-06-26 11:19:04,409 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
[26-Jun-2016 11:19:04] ERROR: unable to bind listening socket for address '/run/php/php7.0-fpm.sock': No such file or directory (2)
[26-Jun-2016 11:19:04] ERROR: FPM initialization failed
2016-06-26 11:19:04,465 INFO exited: php7.0-fpm (exit status 78; not expected)
2016-06-26 11:19:06,470 INFO spawned: 'php7.0-fpm' with pid 21
[26-Jun-2016 11:19:06] ERROR: unable to bind listening socket for address '/run/php/php7.0-fpm.sock': No such file or directory (2)
[26-Jun-2016 11:19:06] ERROR: FPM initialization failed
2016-06-26 11:19:06,527 INFO exited: php7.0-fpm (exit status 78; not expected)
2016-06-26 11:19:09,532 INFO spawned: 'php7.0-fpm' with pid 30
[26-Jun-2016 11:19:09] ERROR: unable to bind listening socket for address '/run/php/php7.0-fpm.sock': No such file or directory (2)
[26-Jun-2016 11:19:09] ERROR: FPM initialization failed
2016-06-26 11:19:09,592 INFO exited: php7.0-fpm (exit status 78; not expected)
2016-06-26 11:19:10,594 INFO gave up: php7.0-fpm entered FATAL state, too many start retries too quickly
2016/06/26 11:19:13 [info] 19#19: *1 client closed connection while waiting for request, client: 192.168.99.1, server: 0.0.0.0:80

Então, minha pergunta é como usar corretamente o supervisord para iniciar o php7.0-fpm / php-fpm7.0 nos contêineres docker.

Também entenda que quando eu faço login nesses containers e executo este comando, então ele começa a funcionar! .. então o que estou fazendo errado

service php7.0-fpm start

quando executo o comando acima depois que o fpm falha ao iniciar quando o contêiner é executado, ele funciona. Mas como eu faço isso com o supervisord? então eu não preciso começar manualmente com o init.d

    
por uberrebu 26.06.2016 / 22:13

2 respostas

4

Eu vejo que não há arquivo /run/php/php7.0-fpm.pid. Este arquivo é criado quando o php7.0-fpm é iniciado. Então, resolvi esse problema adicionando ao Dockerfile:

RUN service php7.0-fpm start

Claro que após a instalação do php-fpm:)

    
por 01.07.2016 / 13:22
11

Criando o /var/run/php na compilação, por exemplo, mkdir -p /var/run/php e, em seguida, iniciando o php-fpm no supervisord

[supervisord]
nodaemon=true

[program:php-fpm]
command=/usr/sbin/php-fpm7.0 -F
autostart=true
autorestart=unexpected
stdout_logfile=/var/log/php-fpm/stdout.log
stdout_logfile_maxbytes=0
stderr_logfile=/var/log/php-fpm/stderr.log
stderr_logfile_maxbytes=0
exitcodes=0

Também funciona.

Se você copiar e colar acima, certifique-se de também mkdir -p /var/log/php-fpm para o supervisord gravar arquivos de log em.

    
por 25.08.2016 / 15:40