Expressjs应用程序从Docker中的PM2开始,随着SIGINT而死

我有一个非常简单的Expressjs应用程序 – 基本上是一个单一的职位电话库封装。

这里是app.js内容:

 var compression = require('compression'); var express = require('express'); var path = require('path'); var bodyParser = require('body-parser'); var convert = require('./routes/convert'); var app = express(); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use(compression()); app.use('/', convert); module.exports = app; 

然后,我创build了Dockerfile来容器化应用程序:

 FROM mhart/alpine-node WORKDIR /src COPY package.json ./ COPY app.js ./ ADD routes/ ./routes/ ADD bin/ ./bin/ RUN npm i RUN npm install -g pm2@2.4.0 EXPOSE 3000 CMD ["pm2-docker", "app.js"] 

当我尝试提出这个问题时(这是DEBUG = express:*)

 [STREAMING] Now streaming realtime logs for [all] processes 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router:route new / 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router:layer new / 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router:route post / 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router:layer new / 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "x-powered-by" to true 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "etag" to 'weak' 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "etag fn" to [Function: wetag] 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "env" to 'development' 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "query parser" to 'extended' 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "query parser fn" to [Function: parseExtendedQueryString] 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "subdomain offset" to 2 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "trust proxy" to false 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "trust proxy fn" to [Function: trustNone] 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application booting in development mode 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "view" to [Function: View] 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "views" to '/src/views' 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:application set "jsonp callback name" to 'callback' 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router use / query 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router:layer new / 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router use / expressInit 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router:layer new / 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router use / jsonParser 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router:layer new / 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router use / urlencodedParser 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router:layer new / 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router use / compression 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router:layer new / 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router use / router 2017-05-14-04:15:09 0|app | Sun, 14 May 2017 04:15:09 GMT express:router:layer new / 2017-05-14-04:15:09 PM2 | App [app] with id [0] and pid [89], exited with code [0] via signal [SIGINT] 2017-05-14-04:15:09 PM2 | Starting execution sequence in -fork mode- for app name:app id:0 2017-05-14-04:15:09 PM2 | App name:app id:0 online 

看起来像过程死亡,然后始终重新启动。 我不是一个Node开发者,只需要这个工作,期待任何的build议和帮助。

谢谢。