[英]AWS elastic beanstalk deploy fails with ENOMEM error
Your AWS Elastic Beanstalk deployment fails: - Intermittent - For no real apparent reason 您的AWS Elastic Beanstalk部署失败: - 间歇性 - 没有明显的原因
Step 1: Check obvious log 第1步:检查明显的日志
/var/log/eb-activity.log /var/log/eb-activity.log
Running npm install: /opt/elasticbeanstalk/node-install/node-v6.10.0-linux-x64/bin/npm
Setting npm config jobs to 1
npm config jobs set to 1
Running npm with --production flag
Failed to run npm install. Snapshot logs for more details.
Traceback (most recent call last):
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
main()
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
node_version_manager.run_npm_install(options.app_path)
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
raise e
subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v6.10.0-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (ElasticBeanstalk::ExternalInvocationError)
caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
Step 2: Google for appropriate Snapshot log file... 第2步:Google提供适当的快照日志文件...
/var/log/nodejs/npm-debug.log /var/log/nodejs/npm-debug.log
58089 verbose stack Error: spawn ENOMEM
58089 verbose stack at exports._errnoException (util.js:1022:11)
58089 verbose stack at ChildProcess.spawn (internal/child_process.js:313:11)
58089 verbose stack at exports.spawn (child_process.js:380:9)
58089 verbose stack at spawn (/opt/elasticbeanstalk/node-install/node-v6.10.0-linux-x64/lib/node_modules/npm/lib/utils/spawn.js:21:13)
58089 verbose stack at runCmd_ (/opt/elasticbeanstalk/node-install/node-v6.10.0-linux-x64/lib/node_modules/npm/lib/utils/lifecycle.js:247:14)
58089 verbose stack at /opt/elasticbeanstalk/node-install/node-v6.10.0-linux-x64/lib/node_modules/npm/lib/utils/lifecycle.js:211:7
58089 verbose stack at _combinedTickCallback (internal/process/next_tick.js:67:7)
58089 verbose stack at process._tickCallback (internal/process/next_tick.js:98:9)
58090 verbose cwd /tmp/deployment/application
58091 error Linux 4.4.44-39.55.amzn1.x86_64
58092 error argv "/opt/elasticbeanstalk/node-install/node-v6.10.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.10.0-linux-x64/bin/npm" "--production" "install"
58093 error node v6.10.0
58094 error npm v3.10.10
58095 error code ENOMEM
58096 error errno ENOMEM
58097 error syscall spawn
58098 error spawn ENOMEM
Step 3: Obvious options... 第3步:明显的选择......
Use a bigger instance and it works... 使用更大的实例,它的工作原理......
Don't fix, just try again 不要修理,再试一次
Deploy again and it works... 再次部署,它的工作原理......
Clone the environment and it works... 克隆环境,它的工作原理......
Rebuild the environment and it works.... 重建环境,它的工作....
Are left feeling dirty and wrong 感觉又脏又错
Your instances (t2.micro in my case) are running out of memory because the instance spin-up is parallelised. 您的实例(在我的情况下为t2.micro)内存不足,因为实例启动是并行化的。
For one-off, while logged into instance... 一次性,登录实例时......
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo chmod 600 /var/swap.1
sudo /sbin/swapon /var/swap.1
From / more detail: How do you add swap to an EC2 instance? 从/更多细节: 如何将交换添加到EC2实例?
During deployment we use a bit of SWAP, but no crash 在部署期间,我们使用了一点SWAP,但没有崩溃
Mem: 1019116k total, 840880k used, 178236k free, 15064k buffers
Swap: 1048572k total, 12540k used, 1036032k free, 62440k cached
Bigger instances 更大的例子
Automate provisioning of swap in ElasticBeanStalk 在ElasticBeanStalk中自动配置交换
.ebextensions/
.ebextensions/
Hop on the 'server-less' bandwagon 加入“无服务器”的潮流
Use less bloated packages 使用较少膨胀的包
A quick google reveals that ENOMEM
is an out of memory error. 一个快速的谷歌揭示
ENOMEM
是一个内存不足的错误。 t2.micro
instances only have 1 GB of RAM. t2.micro
实例只有1 GB的RAM。
Rarely would we use this amount on dev; 我们很少会在开发中使用这个数量; however, ElasticBeanstalk parallelizes parts of the build process through spawned workers.
但是,ElasticBeanstalk通过衍生的工作程序并行化部分构建过程。 This means that during SETUP , for the larger packages, one may run out of memory and the operation will fail.
这意味着在SETUP期间,对于较大的包,可能会耗尽内存并且操作将失败。
Using free -m
we can see... 使用
free -m
我们可以看到......
Start (plenty of free memory) 开始 (充足的空闲记忆)
total used free shared buffers cached
Mem: 1019116 609672 409444 144 45448 240064
-/+ buffers/cache: 324160 694956
Swap: 0 0 0
Ran out of memory at next tick) 下次打勾时内存不足)
Mem: 1019116 947232 71884 144 11544 81280
-/+ buffers/cache: 854408 164708
Swap: 0 0 0
Deploy process aborted 部署过程中止
total used free shared buffers cached
Mem: 1019116 411892 607224 144 13000 95460
-/+ buffers/cache: 303432 715684
Swap: 0 0 0
Rarely would we use this amount on dev;
我们很少会在开发中使用这个数量; however, ElasticBeanstalk parallelizes parts of the build process through spawned workers.
但是,ElasticBeanstalk通过衍生的工作程序并行化部分构建过程。 This means that during SETUP, for the larger packages, one may run out of memory and the operation will fail.
这意味着在SETUP期间,对于较大的包,可能会耗尽内存并且操作将失败。
That's exactly what was happening with me! 这正是我发生的事情! My node.js server worked fine on my dev ec2 t2-micro, but when i deployed a staging enviorment on elastic beanstalk (also with a t2-micro) this error appeared, change the eb instance to t2-small does the trick.
我的node.js服务器在我的dev ec2 t2-micro上运行良好,但是当我在弹性beanstalk(也有t2-micro)上部署了一个临时环境时,出现了这个错误,将eb实例更改为t2-small就是这个技巧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.