Unitech / Unitech/pm2

Testing pm2 vs deno in cluster does not work

Open
#6,042 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

Testing deno with load balancing, I setup an ec2 instance with node, pm2 and deno installed. Pm2 fails using below config.

module.exports = {
  apps : [{
    name: 'app',
    script: '/home/ec2-user/test/app.ts',
    interpreter: "deno",
    interpreter_args: "run --allow-env --allow-net --allow-read --allow-sys",
    instances: "max",
    exec_mode: "cluster",
	  increment_var : 'PORT',
    env: {
      "PORT": 8000,
      "NODE_ENV": "development",
    },
  }]
};

From logs:

Error: Cannot find module '/home/ec2-user/test/run'
    at Function._resolveFilename (node:internal/modules/cjs/loader:1383:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1025:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1030:22)
    at Function._load (node:internal/modules/cjs/loader:1192:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:237:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
    at node:internal/main/run_main_module:36:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

For some reason, the interpreter option is ignored in the config file as pm2 keeps trying to exec run using node. I have tried using absolute path in the interpreter as well to no avail. Running from CLI on a single cpu works pm2 start app.ts --interpreter="deno" --interpreter-args="run --allow-env --allow-net" . Running from CLI with added -i max also fails.

Is this wai? or am I missing smthg? Seems like clusters do not work with deno...

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.

Research direction

Start with the shown PM2 ecosystem configuration and app.ts, then reproduce the working single-CPU command and the failing -i max cluster command. Compare the generated process invocation with the log showing Node trying to load run. Done means cluster mode correctly honors the Deno interpreter and arguments, or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.