【发布时间】:2018-02-17 00:11:29
【问题描述】:
当我尝试使用 pm2 启动 AWS EC2 实例时出现奇怪的问题
aws ec2 run-instances \
--count ${INSTANCE_COUNT} \
--image-id ${IMAGE_ID} \
--region ${REGION} \
--instance-type ${INSTANCE_TYPE} \
--iam-instance-profile Name=${IAM_ROLE} \
--security-group-ids ${SECURITY_GROUP} \
--key-name ${KEY_NAME} \
--subnet-id ${SUBNET_ID} \
--user-data ${BOOTSTRAP}
其中 ${BOOTSTRAP} 是我的文件BOOTSTRAP='file://ec2-bootstrap.sh' 的网址。
问题是它在尝试启动 pm2 守护程序时挂起以下行:
pm2 start ${SERVER_HOME}/index.js --ignore-watch="database node_modules" --watch -- -p80
发生这种情况后,处理器负载 100% 高,虚拟内存用完。
我能找到的唯一东西是关于从属实例 + stdin,例如看here或者here,但是这两篇文章都离解决我的问题太远了。
当我尝试手动运行此命令时,它运行得很好、非常快且符合预期,但如果我尝试使用 at 运行它,假设是
echo '<<the command here>> > ~/test.log' | at now + 1 min
问题已重现。它也挂了...
如何解决这个问题?
提前感谢您,任何帮助将不胜感激
【问题讨论】:
标签: ubuntu amazon-ec2 pm2