oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.01k stars 2.66k forks source link

《Run Bun as a daemon with PM2》 set config to "interpreter: '~/.bun/bin/bun'" has a error #11642

Open mingtianyihou33 opened 3 months ago

mingtianyihou33 commented 3 months ago

What is the type of issue?

Documentation is incorrect

What is the issue?

pm2 version: 5.4.0 system: macbook Apple M1 bun: 1.1.12 This is my ecosystem.config.js.

module.exports = {
  apps: [
    {
      name: 'order-schedule-task',
      script: 'commonTask.ts',
      instances: 1,
      log_date_format: 'YYYY-MM-DD HH:mm:ss:SSS',
      interpreter: '~/.bun/bin/bun',
    },
    {
      name: 'order-app',
      script: 'order.ts',
      instances: 1,
      log_date_format: 'YYYY-MM-DD HH:mm:ss:SSS',
      interpreter: '~/.bun/bin/bun',
    },
    {
      name: 'order-server-proxy',
      script: 'proxy.ts',
      instances: 1,
      log_date_format: 'YYYY-MM-DD HH:mm:ss:SSS',
      interpreter: '~/.bun/bin/bun',
    },
  ],
}

When I execute 'pm2 start ecosystem.config.js' will print below error:

[PM2][WARN] Applications order-schedule-task, order-app, order-server-proxy not running, starting...
[PM2][ERROR] Error: Interpreter ~/.bun/bin/bun is NOT AVAILABLE in PATH. (type 'which ~/.bun/bin/bun' to double check.)
[PM2][ERROR] Error: Interpreter ~/.bun/bin/bun is NOT AVAILABLE in PATH. (type 'which ~/.bun/bin/bun' to double check.)
[PM2][ERROR] Error: Interpreter ~/.bun/bin/bun is NOT AVAILABLE in PATH. (type 'which ~/.bun/bin/bun' to double check.)

If I modify interpreter config to absolute bun path, It will start success. Or modify to 'bun' will too success. Below code will execute to success:

module.exports = {
  apps: [
    {
      name: 'order-schedule-task',
      script: 'commonTask.ts',
      instances: 1,
      log_date_format: 'YYYY-MM-DD HH:mm:ss:SSS',
      interpreter: 'bun',
    },
    {
      name: 'order-app',
      script: 'order.ts',
      instances: 1,
      log_date_format: 'YYYY-MM-DD HH:mm:ss:SSS',
      interpreter: 'bun',
    },
    {
      name: 'order-server-proxy',
      script: 'proxy.ts',
      instances: 1,
      log_date_format: 'YYYY-MM-DD HH:mm:ss:SSS',
      interpreter: 'bun',
    },
  ],
}

It is not known whether the description of the documentation is wrong or the problem of different pm2 versions.

Where did you find it?

No response

Jarred-Sumner commented 3 months ago

pm2 is not expanding ~/.

you'll need to expand that manually