CodeDeploy 错误无法分配内存 - su

Khu*_*boo 5 amazon-web-services aws-code-deploy

codedeploy 在几次部署(php 应用程序)后失败并出现错误

“无法分配内存 - su”,但在实例中它播种了 51% 的内存正在使用中。

可能是什么原因?

Error.
 InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Error during perform: Errno::ENOMEM - Cannot allocate memory - su - /usr/share/ruby/open3.rb:211:in `spawn'
/usr/share/ruby/open3.rb:211:in `popen_run'
/usr/share/ruby/open3.rb:99:in `popen3'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:141:in `execute_script'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:115:in `block (2 levels) in execute'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:103:in `each'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:103:in `block in execute'


[centos@ip-10-196-21-200 codedeploy-agent]$ df
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/xvda1      41926416 21195568  20730848  51% /
devtmpfs          487892        0    487892   0% /dev
tmpfs             507480        0    507480   0% /dev/shm
tmpfs             507480    38336    469144   8% /run
tmpfs             507480        0    507480   0% /sys/fs/cgroup
tmpfs             101496        0    101496   0% /run/user/1000
Run Code Online (Sandbox Code Playgroud)

小智 5

CodeDeploy 代理中可能存在内存泄漏问题:https://github.com/aws/aws-codedeploy-agent/issues/32


Joh*_*ius 5

截至撰写本文时,尚无官方解决方案。

Ubuntu 的临时修复如下。

在您的appspec.yml文件中添加以下内容:

  ValidateService:
    - location: scripts/validate_service.sh
      timeout: 30
      runas: root
Run Code Online (Sandbox Code Playgroud)

在您的脚本文件夹中,创建一个validate_service.sh文件,在文件中添加以下内容:

#!/bin/bash
echo "service codedeploy-agent restart" | at -M now + 2 minute;
Run Code Online (Sandbox Code Playgroud)

这将在每次部署后 2 分钟后重新启动服务。

这是目前正在解决的问题,AWS 似乎正在解决这个问题。RubyZip 似乎正在使用服务器的所有内存并且没有释放它。

在此处阅读更多信息:https ://github.com/aws/aws-codedeploy-agent/issues/32