Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM2 doesnt with with Bun #4949

Open
Meldiron opened this issue Sep 11, 2023 · 21 comments
Open

PM2 doesnt with with Bun #4949

Meldiron opened this issue Sep 11, 2023 · 21 comments
Labels
bug Something isn't working npm Something that relates to the npm-compatible client

Comments

@Meldiron
Copy link

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Linux 5.15.49-linuxkit aarch64 unknown

What steps can reproduce the bug?

Create Dockerfile:

FROM oven/bun:1.0.0
RUN bun install --global pm2
RUN pm2 --help

You get: /bin/sh: 1: pm2: not found

So you try:

FROM oven/bun:1.0.0
RUN bun install --global pm2
RUN bunx --bun pm2 --help

What is the expected behavior?

Show version. Ultimate goal is to later do pm2 start --no-daemon 'bun src/server.ts'

What do you see instead?

error: SystemResources


----- bun meta -----
Bun v1.0.0 (822a00c4) Linux arm64 #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022
BunxCommand: 
Elapsed: 9ms | User: 0ms | Sys: 11ms
RSS: 33.55MB | Peak: 11.87MB | Commit: 33.55MB | Faults: 0
----- bun meta -----

0   0xaaaacd71f478
1   ???
2   ???
3   ???
4   ???
5   ???

Crash report saved to:
  ~/.bun-crash/v1.0.0-1694439849292.crash

Search GitHub issues https://bun.sh/issues or ask for #help in https://bun.sh/discord

Additional information

No response

@Meldiron Meldiron added the bug Something isn't working label Sep 11, 2023
@CodeFromAnywhere
Copy link

Related? #4327

@elendil7
Copy link

Can confirm, am experiencing the same issue.

@vuongphamaioz
Copy link

I run bun with pm2 successfully with this setup:

  • Ubuntu 20
  • Install bun by npm i -g bun, node 18, bun v1.0.0
  • Install pm2 by npm i -g pm2
  • Run by pm2 start "bun my-ts-script.ts"
    Hope it helps!

@calebeaires
Copy link

@vuongphamaioz, I did to, but got this error " errored " if we set -i 3 (multiple clusters)

@vuongphamaioz
Copy link

@calebeaires I just tried -i 3 and it worked. No errors occurred.
pm2 start "bun my-ts-script.ts" -i 3
My script is simple, just an app that sends HTTP requests and interacts with DB.

@calebeaires
Copy link

@vuongphamaioz It were in Nuxt 3

@Electroid
Copy link
Contributor

Thanks for reporting this issue, there are 2 issues here:

@Electroid Electroid added the npm Something that relates to the npm-compatible client label Sep 13, 2023
@omt66
Copy link

omt66 commented Sep 13, 2023

I used this:
pm2 start --interpreter bun src/server.ts
Let me know if there is another way to test this.

@calebeaires
Copy link

Nothin different, when we start more than one cluster

CleanShot 2023-09-14 at 09 15 08@2x

@milahnmartin
Copy link

Any update on this issue ?

@aaron-play
Copy link

The only thing we are not using Bun in production is that we would like to take advantage of multi-core.
We are actually indifferent between using pm2 and cluster module.
We have been testing out different approaches on docker but it doesn't seem stable enough to be on production.
It would be great if one of these could be prioritized.

The link to cluster module issue:
#2428

@lostintheway
Copy link

any way to serve using bun

pm2 serve -s build 3000 --spa

like this?

@sancho1952007
Copy link

Nothin different, when we start more than one cluster

CleanShot 2023-09-14 at 09 15 08@2x

I am facing the exact issue!!!
I am using Elysia in one of my production website but am facaing this issue please help us with this issue!
I think it isn't fully supported for ElysiaJS. How can I get around this?

I think it isn't assigning the ports properly because of bun being a new framework!

PM2 Logs:

2|index    | EADDRINUSE: Failed to start server. Is port 8080 in use?
2|index    |  syscall: "listen"
2|index    | 
2|index    |       at /home/<REDACTED>/node_modules/elysia/dist/bun/index.js:316:40188
2|index    |       at /home/<REDACTED>/src/index.js:62:1

@aaron-play
Copy link

@sancho1952007 try this

new Elysia({ serve: { reusePort: true } })

@sancho1952007
Copy link

@sancho1952007 try this

new Elysia({ serve: { reusePort: true } })

Thanks, I'll try it later!

@toshirot
Copy link

toshirot commented Dec 15, 2023

bun i -g pm2
bun pm2 start "bun app.js"

By the way, is "bun pm2 start app.js" "node app.js"? Or is it "bun app.js"?

@Electroid
Copy link
Contributor

Both of the issues have been fixed:

If you're still experiencing issues with pm2, please open another issue with the error.

@tapz
Copy link

tapz commented Mar 7, 2024

For me it looks like pm2 does not support bun anymore and ignores the interpreter flag completely:

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

.bun/bin/pm2 start --interpreter bun index.js

@Abhid14
Copy link

Abhid14 commented Mar 11, 2024

Same issue here

@Electroid Electroid reopened this Mar 11, 2024
@mrctrifork
Copy link

mrctrifork commented Mar 15, 2024

For me it looks like pm2 does not support bun anymore and ignores the interpreter flag completely:

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

.bun/bin/pm2 start --interpreter bun index.js

The interpreter flag only affects at the binary that is going to execute your index.js.

The problem you're facing (and myself; because I ended up here :) ) is that the pm2 script relies on node.

$: cat $(which pm2)
#!/usr/bin/env node

require('../lib/binaries/CLI.js');
$: 

Usually bunx --bun pm2 ...args should address this. In my machine this results in some prints to the console but no daemons spawned.


To work around this I have installed node in my machine and use pm2 with node and have my apps running with bun. Ideally this shouldnt be necessary

@ironydips
Copy link

Any update on this issue?

Pm2 -i 3 --interpreter=bun runs instances in FORK mode instead of Cluster mode.

Bun version: 1.1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working npm Something that relates to the npm-compatible client
Projects
None yet
Development

No branches or pull requests