代码部署ApplicationStart卡在使用节点的挂起状态 [英] Code Deploy ApplicationStart gets stuck on pending using node

查看:114
本文介绍了代码部署ApplicationStart卡在使用节点的挂起状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用Code Deploy的新手.我正在尝试启动节点应用程序.我的根目录中有setup.sh,start.sh和app.js.

Hi I'm new to using Code Deploy. I am trying to launch a node application. I have setup.sh, start.sh and app.js in my root directory.

这是我的appspec.yml文件

This is my appspec.yml file

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(只是一个基本的虚拟服务器)

app.js (just a basic dummy server)

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);
});

安装"步骤成功完成,但是Code Deploy在执行ApplicationStart步骤时停留在挂起状态.

The Install step successfully completes, but Code Deploy gets stuck on pending when it does the ApplicationStart step.

我很确定这是因为app.js程序连续运行,所以CodeDeploy应该如何知道它正在工作并继续前进?

I'm pretty sure it's because the app.js program runs continously, so how is CodeDeploy supposed to know that it's working and move on?

推荐答案

命令node /app.js不是在后台运行,而是在前台运行,因此start.sh脚本永远不会完成.

The command node /app.js does not run in background but in foreground, therefor the start.sh script is never finished.

有关在后台运行节点的更多信息,请参见此线程. Node.js作为后台服务

See this thread for more info about running node in background Node.js as a background service

这篇关于代码部署ApplicationStart卡在使用节点的挂起状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆