0

VPS:DigitalOcean Amplify:v0.43 Nginx:v1.13.0 PHP-FPM:v7.0.19操作系统:CentOS7

我正在尝试在Nginx-Amplify报告工具中启用php-fpm-metrics 。它工作了几分钟,然后在服务重新启动后出现错误/var/log/amplify-agent/agent.log

agent.conf(相关部分):

[credentials]
api_key = ******************
hostname =
uuid = *******************
imagename =

[nginx]
user = nginx
stub_status = /nginx_status

[extensions]   
phpfpm = True  

agent.log(错误):

2017-05-30 21:30:48,374 [21034] supervisor running /usr/sbin/nginx -t -c /etc/nginx/nginx.conf
2017-05-30 21:31:18,079 [21034] supervisor failed to find php-fpm bin path, last attempt: "ls -la /proc/24400/exe" failed due to AmplifySubprocessError
2017-05-30 20:37:18,394 [9929] supervisor run failed
 Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/amplify/agent/managers/abstract.py", line 135, in _run
self._start_objects()
  File "/usr/lib/python2.7/site-packages/amplify/agent/managers/abstract.py", line 123, in _start_objects
child_obj.start()
File "/usr/lib/python2.7/site-packages/amplify/agent/objects/abstract.py", line 149, in start
context.log.debug('starting object "%s" %s' % (self.type, self.definition_hash))
File "/usr/lib/python2.7/site-packages/amplify/agent/objects/abstract.py", line 84, in definition_hash
definition_string = str(map(lambda x: u'%s:%s' % (x, self.definition[x]), sorted(self.definition.keys())))
File "/usr/lib/python2.7/site-packages/amplify/ext/abstract/object.py", line 47, in definition
return {'type': self.type, 'local_id': self.local_id, 'root_uuid': self.root_uuid}
File "/usr/lib/python2.7/site-packages/amplify/agent/objects/abstract.py", line 115, in local_id
self._local_id = hashlib.sha256('_'.join(self.local_id_args)).hexdigest()
TypeError: sequence item 0: expected string, list found

PHP-FPM /etc/php-fpm.d/www.conf (相关部分):

[www]
user = nginx
group = nginx

listen = /var/run/php-fpm/php-fpm.sock
listen.backlog = 16383
listen.allowed_clients = 127.0.0.1

pm = dynamic
pm.max_children = 25
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.max_requests = 500

pm.status_path = /php_status

Nginx.conf(相关部分):

user nginx nginx;

如文档中所述,这有效

$ SCRIPT_NAME=/php_status SCRIPT_FILENAME=/php_status QUERY_STRING= REQUEST_METHOD=GET cgi-fcgi -bind -connect /var/run/php-fpm/php-fpm.sock

结果:

X-Powered-By: PHP/7.0.19
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Content-type: text/plain;charset=UTF-8

pool:                 www
process manager:      dynamic
start time:           29/May/2017:15:40:29 +0200
start since:          107193
accepted conn:        806252
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       10
active processes:     14
total processes:      24
max active processes: 25
max children reached: 1840
slow requests:        330

我想问题是,一段时间后重新启动过程和“更改” pid:

supervisor failed to find php-fpm bin path, last attempt: "ls -la /proc/24400/exe" failed due to AmplifySubprocessError

不确定,但可能pm.max_requests = 500对此负责。

4

1 回答 1

2

感谢您的报告!

这里有两个问题会影响您的系统。首先是我们无法找到bin_path您的phpfpmvia ls

supervisor failed to find php-fpm bin path, last attempt: "ls -la /proc/24400/exe" failed due to AmplifySubprocessError

这意味着我们的代理运行的用户无权访问proc您的phpfpm主进程或其任何子池的文件系统。此信息纯粹是元相关的,不应影响代理的运行或它phpfpm从其状态页面收集的指标。我们收集的信息是您的bin_path,然后我们在其上运行--version以收集有关您的版本信息phpfpm,以便显示在您的库存中。

也就是说,我们将0.44在本周末(2017 年 6 月 16 日星期五)或下周初(2017 年 6 月 19 日星期一)发布一个新代理,该代理对此工作流程进行了许多改进,可能会使您受益。

影响您的系统的第二个问题更为严重,可能会影响您的代理运行时:

17-05-30 21:31:18,079 [21034] supervisor failed to find php-fpm bin path, last attempt: "ls -la /proc/24400/exe" failed due to AmplifySubprocessError
2017-05-30 20:37:18,394 [9929] supervisor run failed
 Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/amplify/agent/managers/abstract.py", line 135, in _run
self._start_objects()
  File "/usr/lib/python2.7/site-packages/amplify/agent/managers/abstract.py", line 123, in _start_objects
child_obj.start()
File "/usr/lib/python2.7/site-packages/amplify/agent/objects/abstract.py", line 149, in start
context.log.debug('starting object "%s" %s' % (self.type, self.definition_hash))
File "/usr/lib/python2.7/site-packages/amplify/agent/objects/abstract.py", line 84, in definition_hash
definition_string = str(map(lambda x: u'%s:%s' % (x, self.definition[x]), sorted(self.definition.keys())))
File "/usr/lib/python2.7/site-packages/amplify/ext/abstract/object.py", line 47, in definition
return {'type': self.type, 'local_id': self.local_id, 'root_uuid': self.root_uuid}
File "/usr/lib/python2.7/site-packages/amplify/agent/objects/abstract.py", line 115, in local_id
self._local_id = hashlib.sha256('_'.join(self.local_id_args)).hexdigest()
TypeError: sequence item 0: expected string, list found

我不能肯定你的系统,但是当我们的代理发现一个孤立的phpfpm pool工人时,其他客户已经报告了这个错误。例如,输出ps xao pid,ppid,command | grep 'php-fpm[:]'可能是:

[
    '15923     1 php-fpm: master process (/etc/php-fpm.conf)',
    '20704 15923 php-fpm: pool www',
    '20925 15923 php-fpm: pool www',
    '21350 15923 php-fpm: pool www',
    '21385 15923 php-fpm: pool www',
    '21386 15923 php-fpm: pool www',
    '21575 15923 php-fpm: pool www',
    '21699 15923 php-fpm: pool www',
    '21734 15923 php-fpm: pool www',
    '21735 15923 php-fpm: pool www',
    '21781 15923 php-fpm: pool www',
    '21782 15923 php-fpm: pool www',
    '22287 15923 php-fpm: pool www',
    '22330 15923 php-fpm: pool www',
    '22331 15923 php-fpm: pool www',
    '22495 15923 php-fpm: pool www',
    '22654 21386 php-fpm: pool www',  # <---- Orphan?
    ''
]

我们仍在调查可能导致这种情况的原因,但目前我们通过静默处理这种情况使我们的代理更加健壮。可以在我们的代理版本中找到此修复程序,0.44如上文所述,该版本应尽快发布。

如果您仍然感兴趣,我强烈建议您在代理0.44发布时下载并安装它。如果您的系统仍然存在问题,请随时通过我们的客户支持渠道与我们联系。

我还建议您考虑检查您自己的系统,看看您是否有任何“孤儿”池工作人员,因为它有可能表明其他问题。但同样,我们的新代理将适当地捕捉和处理这种情况。

我希望这有帮助!

Grant(NGINX Amplify 代理贡献者)

于 2017-06-14T20:55:23.153 回答