Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.61k stars 2.62k forks source link

migrate to bun #5774

Open Mrgaton opened 9 months ago

Mrgaton commented 9 months ago

pm2 logs uses 30% of resources of my machine, im using it on a potato but a bun version would be great

ultimate-tester commented 9 months ago

You want to use bun as interpreter?

pm2 start --interpreter ~/.bun/bin/bun

Mrgaton commented 9 months ago

Won't be nice to make that as default?

I don't see any disadvantage of not using bun

ultimate-tester commented 9 months ago

It won't be as easy as just stating "let's make a different interpreter the default". Here's some cons just for sake of argument:

So, while Node.js is still the most popular, complete and stable production-ready interpreter, in my opinion PM2 should stick with it and only start discussing about it when Node.js is surpassed in those areas.

Nothing against Bun, but you have to be realistic.

Mrgaton commented 9 months ago

You want to use bun as interpreter?

pm2 start --interpreter ~/.bun/bin/bun

how i can make it permament and then how i can leave it as default?

ultimate-tester commented 9 months ago

Actually coming back to this, it seems that bun is the default already for typescript (bad decision if you ask me) since oct 6 2023: https://github.com/Unitech/pm2/commit/135c123adcb207f9c544bcc6c6853c3f8488fb31

That would mean that if you really want to use bun by default, either modify that file manually or use typescript extension.

tapz commented 8 months ago

I can't get pm2 to work with bun at all. Whatever I do pm2 always gives this error:

/usr/bin/env: 'node': No such file or directory

I have tried with command line arguments and with a configuration file. Still it seems to ignore the interpreter argument completely.

.bun/bin/pm2 start ecosystem.json .bun/bin/pm2 start --interpreter bun index.js .bun/bin/pm2 start --interpreter /usr/local/bin/bun index.js

ecosystem.json:

{
  "apps": [
    {
      "name": "myapp",
      "script": "index.js",
      "interpreter": "/usr/local/bin/bun",
      "instances": 1,
      "exec_mode": "fork",
      "autorestart": true,
      "watch": false,
      "error_file": "./errors.log",
      "out_file": "./myapp.log"
    }
  ]
}
terebentina commented 4 months ago

You can run it with bun --bun pm2 start. This will run bun instead of node, however, you'll immediately hit the next problem: cluster mode is not yet implemented in bun and pm2 tries to use that. Which will throw an error and exit.


Later edit: bun 1.1.25 has added support for cluster mode so the command above seems to be working now 💥

mavyfaby commented 3 months ago

But it doesn't on work on ts bun files, it still shows:

Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
harryqt commented 2 months ago

cluster mode is not yet implemented in bun

Not anymore. See: https://bun.sh/blog/bun-v1.1.25#node-cluster-support

PayasoConEstilo commented 2 months ago

i think we should migrate to run always in bun by default if installed

mario-huang commented 1 month ago

Hi all, I find a workaround. https://github.com/Unitech/pm2/issues/5893#issuecomment-2395029376

FreTimmerman commented 1 month ago

You can run it with bun --bun pm2 start.

this results for me in error: Script not found "pm2" I had to perform bun --bun run pm2 start index.ts

Unitech commented 2 weeks ago

Full Bun support is available in beta, please could you try it and report me any bugs:

bun install pm2-beta -g
pm2 update

Thanks