当我尝试使用 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
,例如看这里或这里,但是这两篇文章都离解决我的问题太远了。
当我尝试手动运行此命令时,它工作得很好,非常快并且符合预期,但是如果我尝试使用 运行它at
,让我们说
echo '<<the command here>> > ~/test.log' | at now + 1 min
问题重现。也挂了...
如何解决这个问题?
提前感谢您,任何帮助将不胜感激