'Trying to start pm2-runtime with 3 instances for a MEAN application

I am trying to start an existing MEAN stack app in a Docker container by using the following Docker command:

CMD ["pm2-runtime", "-i", "3", "npm", "--", "run-script", "start:prod"]

That command does start 3 PM2 instances, however it seems that the npm portion is not running the run-script part and it hangs with the following message in each instance:

Usage: npm <command>
where <command> is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get,
    help, help-search, i, init, install, install-test, it, link,
    list, ln, login, logout, ls, outdated, owner, pack, ping,
    prefix, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, tag, team, test, tst, un, uninstall,

If I remove the "-i", "3" portion, it correctly starts 1 instance of the app in "fork" mode.

Anyone know what would be the correct syntax for starting 3 instances, considering its using NPM with a run-script?

Thank you



Solution 1:[1]

-- is a bash-specific feature which signifies the end of command line options.

You are however not running bash, but calling the pm2-runtime binary and passing the arguments to it.

Thus it's essentially equivalent to calling npm with -- as the command.

I think that -- can be removed and it should work.

Solution 2:[2]

Add "start" to CMD line

CMD ["pm2-runtime", "start", "-i", "3", "npm", "--", "run-script", "start:prod"]

Solution 3:[3]

The code below is worked well for me.

- module: gcp
  metricsets:
    - metrics
  project_id: "YOUR_PROJECT_ID"
  credentials_file_path: "your JSON credentials file path"
  exclude_labels: false
  period: 1800s # 1800s is recommended
  metrics:
    - aligner: ALIGN_NONE
      service: bigquery
      service_metric_prefix: bigquery.googleapis.com/ # This is not required as already "bigquery.googleapis.com/" is default value
      metric_types:
        - "storage/table_count" #only "storage/table_count" here

It seems that you should edit your metric_type attribute only.

I recommend the collection period of table_count metric to 1800s as GCP sampled this every 1800 seconds.

Refer here for the information about that.

This works well at my kibana too.

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Uku Loskit
Solution 2 nguyen_vts
Solution 3