Docker and commander js

Open
#5,232 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
docker, javascript, node.js
Domain
cli, devops

Research direction

Start with the supplied Dockerfile and compare the two pm2-runtime command forms against the reported PM2 5.1.2 argv. Read the pm2-runtime CLI entry point and the ecosystem.config.js and app.js examples, then reproduce the unknown-command errors in a Node 16 Docker container. Done means the documented invocation starts the configured app and passes its clone arguments without treating them as unsupported commands.

Written by the indexing model from the issue text.

Description

What's going wrong?

I am using CMD ["pm2-runtime", "start", "ecosystem.config.js", "--env", "production"] in my Dockerfile to run my applications in the docker via pm2
Outside of docker pm2 start ecosystem.config.js --env production works well

but in the docker, When I run pm2 log 0 I have error like error: unknown command 'start'
When I using CMD ["pm2-runtime", "ecosystem.config.js", "--env", "production"] the error is error: unknown command 'ecosystem.config.js'

How could we reproduce this issue?

app.js

const { program } = require('commander');

program
  .command('clone <source> [destination]')
  .description('clone a repository into a newly created directory')
  .action((source, destination) => {
    console.log('clone command called');
  });

ecosystem.config.js

module.exports = [{
  script: 'app.js',
  name: 'app',
  args: 'clone foo bar',
  instances: 2
}

Dockerfile

FROM node:16 
RUN npm install pm2 -g
CMD ["pm2-runtime", "ecosystem.config.js"]

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Tue Nov 30 2021 13:15:01 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 5.1.2
node version         : 16.13.0
node path            : not found
argv                 : /usr/local/bin/node,/usr/local/bin/pm2-runtime,start,ecosystem.config.js,--env,production
argv0                : node
user                 : undefined
uid                  : 0
gid                  : 0
uptime               : 0min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 5.1.2
node version         : 16.13.0
node path            : not found
argv                 : /usr/local/bin/node,/usr/local/bin/pm2,report
argv0                : node
user                 : undefined
uid                  : 0
gid                  : 0
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz
cpus nb              : 4
freemem              : 3189035008
totalmem             : 9893634048
home                 : /root
===============================================================================
Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Unitech/pm2

All issues in Unitech/pm2

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.