您好,我是使用 Code Deploy 的新手。我正在尝试启动节点应用程序。我的根目录中有 setup.sh、start.sh 和 app.js。
这是我的 appspec.yml 文件
version: 0.0
os: linux
files:
- source: /
destination: /
hooks:
Install:
- location: setup.sh
timeout: 3600
ApplicationStart:
- location: start.sh
timeout: 3600
setup.sh
yum -y install nodejs npm --enablerepo=epel
npm install
start.sh
node /app.js
app.js(只是一个基本的虚拟服务器)
var express = require("express");
var app = express();
app.get("/",function(req,res) {
res.send("Hello world")
})
var server = app.listen(8080,function() {
console.log("Listening at " + server.address().address + ": " + server.address().port);
});
Install 步骤成功完成,但 Code Deploy 在执行 ApplicationStart 步骤时陷入挂起状态。
我很确定这是因为 app.js 程序连续运行,那么 CodeDeploy 应该如何知道它正在工作并继续前进?
CodeDeploy 代理正在等待其启动的脚本返回退出代码并关闭stdout
and stderr
。要在后台启动进程并将其与主机代理分离,以便它可以作为守护进程运行,请尝试:
node /app.js > /dev/null 2> /dev/null < /dev/null &
注意:您需要修改程序以写入日志文件而不是控制台,因为守护程序通常没有可写入的控制台(正如本版本中所示)。
请参阅此处的官方文档:http://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting.html#troubleshooting-long-running-processes http://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting.html#troubleshooting-long-running-processes
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)