Open Meldiron opened 1 year ago
Can confirm, am experiencing the same issue.
I run bun with pm2 successfully with this setup:
npm i -g bun
, node 18, bun v1.0.0
npm i -g pm2
pm2 start "bun my-ts-script.ts"
Hope it helps!@vuongphamaioz, I did to, but got this error " errored " if we set -i 3
(multiple clusters)
@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.
@vuongphamaioz It were in Nuxt 3
Thanks for reporting this issue, there are 2 issues here:
I used this: pm2 start --interpreter bun src/server.ts Let me know if there is another way to test this.
Nothin different, when we start more than one cluster
Any update on this issue ?
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: https://github.com/oven-sh/bun/issues/2428
any way to serve using bun
pm2 serve -s build 3000 --spa
like this?
Nothin different, when we start more than one cluster
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
@sancho1952007 try this
new Elysia({ serve: { reusePort: true } })
@sancho1952007 try this
new Elysia({ serve: { reusePort: true } })
Thanks, I'll try it later!
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"?
Both of the issues have been fixed:
If you're still experiencing issues with pm2
, please open another issue with the error.
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
Same issue here
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
Any update on this issue?
Pm2 -i 3 --interpreter=bun runs instances in FORK mode instead of Cluster mode.
Bun version: 1.1.6
Would also like to know if there is an update here. No success with any of the above approaches.
Same here. I have to install Node in order to use pm2 at all.
For now I'm installing Node to use pm2 as well
I tried pm2.json5 config file:
{
name: 'device_log',
script: 'bun',
args: '--bun run start',
interpreter: '/root/.bun/bin/bun',
exec_mode: 'fork',
instances: 1,
env: {
NODE_ENV: 'production',
},
}
But the program fails. How could we run bun --bun run start
in PM2 config file?
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!
npm needs nods js
how to do it only with bun
Hi all, I find a workaround. https://github.com/Unitech/pm2/issues/5893#issuecomment-2395029376
I was getting the same error as @tapz when running pm2
with Bun.
$ bun add --global pm2@latest
$ pm2 ls
/usr/bin/env: 'node': No such file or directory
$ head $(which pm2) -n 1
#!/usr/bin/env node
Instead of installing Node.js, I was able to solve it by creating a symlink named node
to run bun
.
$ which bun
/home/ubuntu/.bun/bin/bun
$ cd ~/bin
$ ln -s ~/.bun/bin/bun node
The above assumes that the directory ~/bin
exists and is in your $PATH
. For example, defined in ~/.bashrc
.
export PATH=$HOME/bin:$PATH
I use WSL2, and its ok. Looks like it would only be a problem on windows?
It is now fixed at dev branch
Nice solution in pm2
.
# Check if 'bun' is available, otherwise use 'node'
if command -v bun &> /dev/null
then
bun "$SCRIPT_PATH" "$@"
else
node "$SCRIPT_PATH" "$@"
fi
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:
You get:
/bin/sh: 1: pm2: not found
So you try:
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?
Additional information
No response