volta-cli / volta

Volta: JS Toolchains as Code. ⚡
https://volta.sh
Other
11.15k stars 238 forks source link

pm2 startup failed with "thread 'main' panicked at 'failed to spawn thread: Os" #1570

Open halofe opened 1 year ago

halofe commented 1 year ago
➜  demo-app git:(main) ✗ pm2 startup
[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/home/ubuntu/.volta/tools/image/node/21.1.0/bin /home/ubuntu/.volta/tools/image/packages/pm2/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu
➜  demo-app git:(main) ✗ sudo env PATH=$PATH:/home/ubuntu/.volta/tools/image/node/21.1.0/bin /home/ubuntu/.volta/tools/image/packages/pm2/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu
thread 'main' panicked at 'failed to spawn thread: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ctrlc-3.2.4/src/lib.rs:117:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
➜  demo-app git:(main) ✗ sudo env PATH=$PATH pm2 startup systemd -u ubuntu --hp /home/ubuntu
thread 'main' panicked at 'failed to spawn thread: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ctrlc-3.2.4/src/lib.rs:117:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
➜  demo-app git:(main) ✗ volta -v
1.1.1
➜  demo-app git:(main) ✗ node -v
v21.1.0
➜  demo-app git:(main) ✗ pm2 -v
5.3.0
➜  demo-app git:(main) ✗ which node
/home/ubuntu/.volta/bin/node
➜  demo-app git:(main) ✗ which pm2
/home/ubuntu/.volta/bin/pm2
➜  demo-app git:(main) ✗ ls -l $VOLTA_HOME/bin
total 34228
lrwxrwxrwx 1 ubuntu ubuntu       34 Nov  4 00:36 node -> /home/ubuntu/.volta/bin/volta-shim
lrwxrwxrwx 1 ubuntu ubuntu       34 Nov  4 00:36 npm -> /home/ubuntu/.volta/bin/volta-shim
lrwxrwxrwx 1 ubuntu ubuntu       34 Nov  4 00:36 npx -> /home/ubuntu/.volta/bin/volta-shim
lrwxrwxrwx 1 ubuntu ubuntu       34 Nov 10 11:34 pm2 -> /home/ubuntu/.volta/bin/volta-shim
lrwxrwxrwx 1 ubuntu ubuntu       34 Nov 10 11:34 pm2-dev -> /home/ubuntu/.volta/bin/volta-shim
lrwxrwxrwx 1 ubuntu ubuntu       34 Nov 10 11:34 pm2-docker -> /home/ubuntu/.volta/bin/volta-shim
lrwxrwxrwx 1 ubuntu ubuntu       34 Nov 10 11:34 pm2-runtime -> /home/ubuntu/.volta/bin/volta-shim
lrwxrwxrwx 1 ubuntu ubuntu       34 Nov  4 00:36 pnpm -> /home/ubuntu/.volta/bin/volta-shim
-rwxr-xr-x 1 ubuntu ubuntu 13299508 Jan 25  2023 volta
-rwxr-xr-x 1 ubuntu ubuntu  9577448 Jan 25  2023 volta-migrate
-rwxr-xr-x 1 ubuntu ubuntu 12167481 Jan 25  2023 volta-shim
lrwxrwxrwx 1 ubuntu ubuntu       34 Nov  4 00:36 yarn -> /home/ubuntu/.volta/bin/volta-shim
➜  demo-app git:(main) ✗ echo $PATH
/home/ubuntu/.volta/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ubuntu/.local/bin
shangxinbo commented 11 months ago

same error

chriskrycho commented 11 months ago

How odd! Can you share the results of running with RUST_BACKTRACE=1, as the error output indicates? That will help us see why it's going wrong that way.

shangxinbo commented 11 months ago

我试过了,使用volta或者类似的node管理工具时,node和PM2安装是只给一个用户安装,所以在执行sudo命令时会有问题,可以尝试给root安装pm2解决。 因为这个问题我决定以后再也不用nvm,volta这种东西了


Edit by @chriskrycho: Adding an automated translation from Apple:

I have tried. When using volta or similar node management tools, node and PM2 installation are only installed for one user, so there will be problems when executing sudo commands. You can try to install pm2 for root.

Because of this problem, I decided not to use nvm and volta again.

halofe commented 11 months ago

The command succeed after sudo -i

➜  ~ pm2 startup
[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/home/ubuntu/.volta/tools/image/node/21.1.0/bin /home/ubuntu/.volta/tools/image/packages/pm2/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu
➜  ~ sudo -i
root@e1:~# env PATH=$PATH:/home/ubuntu/.volta/tools/image/node/21.1.0/bin /home/ubuntu/.volta/tools/image/packages/pm2/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu
[PM2] Init System found: systemd
halofe commented 11 months ago

How odd! Can you share the results of running with RUST_BACKTRACE=1, as the error output indicates? That will help us see why it's going wrong that way.

Tried with RUST_BACKTRACE=1, error with "pm2 not found"