атомарное развертывание с Nginx и PHP FPM

Я пытаюсь получить атомарное развертывание, я не хочу терять/отбрасывать любые запросы.

Я развертываю использование кода Capistrano, классическая ситуация была Вами, имеют 'текущий' dir, который является символьной ссылкой на последний выпуск в папке 'выпуска'. Я использую Nginx, PHP 5,5 футов в минуту с Opcache. После идеи просто использования $realpath_root в Nginx я ожидаю, что простая перезагрузка nginx была бы достаточна, но это не. С перезагрузкой nginx кажется, что я не теряю запросов, но php-fpm все еще выполняет код от предыдущего старого dir, Если я делаю 'php-fpm, перезагрузка' затем php fpm читает из нового dir, но я могу все еще видеть, что теряю некоторые запросы:

'recv () перестал работать (104: Соединение, сброшенное одноранговым узлом) при чтении заголовка ответа из восходящего потока'

Вопрос: я должен перезагрузить PHP FPM или нет?

Из того, что я понимаю, что nginx передает путь к php-fpm, и от nginx отладка регистрируется I, видят, что путь передал, правильный, но php-fpm все еще выполняет старый.

2014/09/23 17:13:22 [debug] 26234#0: *1742 http script var: "/shop/www/htdocs/current/web"
2014/09/23 17:13:22 [debug] 26234#0: *1742 posix_memalign: 00000000010517A0:4096 @16
2014/09/23 17:13:22 [debug] 26234#0: *1742 http script copy: "SCRIPT_FILENAME"
2014/09/23 17:13:22 [debug] 26234#0: *1742 http script var: "/shop/www/htdocs/ive/releases/20140923124417/web"
2014/09/23 17:13:22 [debug] 26234#0: *1742 http script var: "/app.php"
2014/09/23 17:13:22 [debug] 26234#0: *1742 fastcgi param: "SCRIPT_FILENAME: /shop/www/htdocs/live/releases/20140923124417/web/app.php"
2014/09/23 17:13:22 [debug] 26234#0: *1742 http script copy: "DOCUMENT_ROOT"
2014/09/23 17:13:22 [debug] 26234#0: *1742 http script var: "/shop/www/htdocs/live/releases/20140923124417/web"
2014/09/23 17:13:22 [debug] 26234#0: *1742 fastcgi param: "DOCUMENT_ROOT: /shop/www/htdocs/live/releases/20140923124417/web"
2014/09/23 17:13:22 [debug] 26234#0: *1742 http script copy: "APPLICATION_ENV"

Что я пропускаю?спасибо

1
задан 23 September 2014 в 21:26
2 ответа

Похоже, вы внесли изменения в конфигурацию OPcache по умолчанию.

Значения по умолчанию:

opcache.validate_timestamps = 1
opcache.revalidate_freq = 2

Это указывает, должен ли OPcache ждать и как долго перед проверкой наличия файла на диске поменялось. В этом случае - да, и через две секунды.

Сначала попробуйте снова включить эту опцию, поскольку похоже, что вы ее отключили.

0
ответ дан 4 December 2019 в 08:31

Я тоже столкнулся с этой проблемой, и, наконец, я решил ее.

$ curl -sO http://gordalina.github.io/cachetool/downloads/cachetool.phar
$ chmod +x cachetool.phar

Вы можете подключиться к автоматически определяемому серверу fastcgi (если /var/run/php5-fpm.sock - это файл или 127.0.0.1:9000)

apc
  apc:bin:dump             Get a binary dump of files and user variables
  apc:bin:load             Load a binary dump into the APC file and user variables
  apc:cache:clear          Clears APC cache (user, system or all)
  apc:cache:info           Shows APC user & system cache information
  apc:cache:info:file      Shows APC file cache information
  apc:key:delete           Deletes an APC key
  apc:key:exists           Checks if an APC key exists
  apc:key:fetch            Shows the content of an APC key
  apc:key:store            Store an APC key with given value
  apc:sma:info             Show APC shared memory allocation information
opcache
  opcache:configuration    Get configuration information about the cache
  opcache:reset            Resets the contents of the opcode cache
  opcache:status           Show summary information about the opcode cache
  opcache:status:scripts   Show scripts in the opcode cache

Пример:

    [root@ip-172-31-5-244 ~]# php cachetool.phar opcache:status
+----------------------+---------------------------------+
| Name                 | Value                           |
+----------------------+---------------------------------+
| Enabled              | Yes                             |
| Cache full           | No                              |
| Restart pending      | No                              |
| Restart in progress  | No                              |
| Memory used          | 42.71 MiB                       |
| Memory free          | 85.29 MiB                       |
| Memory wasted (%)    | 0 b (0%)                        |
| Strings buffer size  | 8 MiB                           |
| Strings memory used  | 5.31 MiB                        |
| Strings memory free  | 2.69 MiB                        |
| Number of strings    | 103847                          |
+----------------------+---------------------------------+
| Cached scripts       | 1261                            |
| Cached keys          | 2748                            |
| Max cached keys      | 7963                            |
| Start time           | Thu, 08 Feb 2018 02:28:56 +0000 |
| Last restart time    | Thu, 08 Feb 2018 03:10:19 +0000 |
| Oom restarts         | 0                               |
| Hash restarts        | 0                               |
| Manual restarts      | 1                               |
| Hits                 | 47839                           |
| Misses               | 1269                            |
| Blacklist misses (%) | 0 (0%)                          |
| Opcache hit rate     | 97.415899649752                 |
+----------------------+---------------------------------+
[root@ip-172-31-5-244 ~]#
[root@ip-172-31-5-244 ~]#
[root@ip-172-31-5-244 ~]# php cachetool.phar opcache:reset
[root@ip-172-31-5-244 ~]#
[root@ip-172-31-5-244 ~]#
[root@ip-172-31-5-244 ~]# php cachetool.phar opcache:status
+----------------------+---------------------------------+
| Name                 | Value                           |
+----------------------+---------------------------------+
| Enabled              | Yes                             |
| Cache full           | No                              |
| Restart pending      | No                              |
| Restart in progress  | No                              |
| Memory used          | 10.43 MiB                       |
| Memory free          | 117.57 MiB                      |
| Memory wasted (%)    | 0 b (0%)                        |
| Strings buffer size  | 8 MiB                           |
| Strings memory used  | 545.69 KiB                      |
| Strings memory free  | 7.47 MiB                        |
| Number of strings    | 103847                          |
+----------------------+---------------------------------+
| Cached scripts       | 0                               |
| Cached keys          | 0                               |
| Max cached keys      | 7963                            |
| Start time           | Thu, 08 Feb 2018 02:28:56 +0000 |
| Last restart time    | Thu, 08 Feb 2018 03:19:00 +0000 |
| Oom restarts         | 0                               |
| Hash restarts        | 0                               |
| Manual restarts      | 2                               |
| Hits                 | 0                               |
| Misses               | 2                               |
| Blacklist misses (%) | 0 (0%)                          |
| Opcache hit rate     | 0                               |
+----------------------+---------------------------------+

Вы можете заметить, что память, ключи кеша, все обращения стали 0 :-). Это очень полезно. Я также легко заинтриговал его с помощью Ansible.

Его приложение для apcu и других вещей: подробнее см. http://gordalina.github.io/cachetool/

0
ответ дан 4 December 2019 в 08:31

Теги

Похожие вопросы