嗨,我是使用 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
Run Code Online (Sandbox Code Playgroud)
设置文件
yum -y install nodejs npm --enablerepo=epel
npm install
Run Code Online (Sandbox Code Playgroud)
启动文件
node /app.js
Run Code Online (Sandbox Code Playgroud)
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);
});
Run Code Online (Sandbox Code Playgroud)
安装步骤成功完成,但代码部署在执行 ApplicationStart 步骤时卡在挂起状态。
我很确定这是因为 app.js …