How to pass in node args during post deploy?

Open
#5,438 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
30/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript, nodejs
Domain
cli, devops

Research direction

Start with the ecosystem.config.js deploy configuration and the post-deploy command shown in the issue; trace how PM2 invokes the application and how arguments reach process.argv. Done means the requested argument is present during post-deploy startup without being applied on every startup.

Written by the indexing model from the issue text.

Description

I'm using an ecosystem.config.js file. I need to pass in an argument when starting my app but only during post deploy startup.

I know I can use

{
  "apps": [
    {
      "name": "myApp",
      "script": "./myApp.js",
      "args": "--randomArgs"
    }
  ]
}

but that passes the args on every startup.

I also tried putting the args behind -- in the post deploy string but they're not showing up in process.argv.

deploy : {
    development : {
       "user" : "ubuntu",
       "host" : ["192.168.0.13", "192.168.0.14", "192.168.0.15"],
       "ref"  : "origin/master",
       "repo" : "git@github.com:Username/repository.git",
       "path" : "/var/www/my-repository",
       "post-deploy" : "npm install && pm2 startOrRestart ecosystem.config.js --randomArgs --update-env --env development"
    }
  }

How can this be accomplished?

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.