Expressjs app started with PM2 in Docker dies with SIGINT

I have a VERY SIMPLE Expressjs app – basically a library wrapper with the single post call.

Here is the app.js conents:

  • HEALTHCHECK of a Docker container running Celery tasks?
  • Swarm: Get Node Ip and Container IP from service
  • Docker, and small production server infrastructure advices
  • Docker - Enable Remote HTTP API with SystemD and “daemon.json”
  • Docker Alpine /bin/sh apk not found
  • How to start a docker container when windows boots
  • 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;
    

    Then I created Dockerfile to containerize the app:

    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"]
    

    And here is what happens when I try to bring it up (this is with the 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
    

    looks like that process dies and being restarted then all the time. I’m not a Node developer just need this one get working and looking forward to any suggestions and help.

    Thanks.

  • pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver
  • how to create an All-In-One docker image using sbt-docker and sbt-assembly
  • Trouble executing lsb-release in a Bitbucket Pipelines docker instance
  • Symfony environment in Docker container
  • Passing envs into gradle build?
  • Docker bridge not showing - is it optional or incorrectly configured?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.