jessety / pm2-installer

Install PM2 offline as a service on Windows or Linux. Mostly designed for Windows.
MIT License
494 stars 50 forks source link

Error: connect EPERM //./pipe/rpc.sock #12

Closed rossm-mf closed 4 years ago

rossm-mf commented 4 years ago

Description Installation went well but I have an error when I try to see if pm2 is running with pm2 ps. I googled a little and some people talk about run as admin, which I already did. It seems to be related to the way we install pm2 on the machine. maybe you guys can help me on that part.

Steps to Reproduce

  1. install like stated in the README
  2. run pm2 ps

The Error

>pm2 ps
connect EPERM //./pipe/rpc.sock
[PM2] Spawning PM2 daemon with pm2_home=C:\ProgramData\pm2\home
events.js:287
      throw er; // Unhandled 'error' event
      ^

Error: connect EPERM //./pipe/rpc.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Emitted 'error' event on ReqSocket instance at:
    at Socket.<anonymous> (C:\ProgramData\npm\npm\node_modules\pm2\node_modules\pm2-axon\lib\sockets\sock.js:201:49)
    at Socket.emit (events.js:310:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'EPERM',
  code: 'EPERM',
  syscall: 'connect',
  address: '//./pipe/rpc.sock'
}

Environment

Running on: 9/11/2020, pm2-installer 3.0.2 with node v12.16.3 and npm 6.14.4 on win32-10.0.19042.

I ended with that on my global package list.

>npm list --depth=0 -g
C:\ProgramData\npm\npm
+-- node-windows@1.0.0-beta.1
+-- pm2@4.4.0
`-- pm2-logrotate@2.7.0
jessety commented 4 years ago

Hi @rossm-mf,

That looks like an error that occurs when you attempt to invoke pm2 from a non-admin terminal. For the CLI to communicate with the instance of pm2 running in the service, it needs to be running in an elevated console. Otherwise it'll fail, attempt to spawn a daemon itself, then fail at that as well.

Make sure to right click and say "Run as Administrator" when starting a new console session.

Hope this is helpful!

Screen Shot 2020-09-12 at 22 31 31 PM
rossm-mf commented 4 years ago

I was using windows-terminal and for some reason it was not working. Now after few reboots, it's fine.

jessety commented 4 years ago

Hey @rossm-mf,

I'm a pretty big fan of Windows Terminal, but it does come with a few caveats that I've noticed while working on this project. One is that (unlike the standard Powershell interface) you can't right click the icon in the task bar and select "run as admin." Instead, you have to search for it in the Start menu and select "run it as admin" from there. I believe this restriction has something to do with packaging the app for the Windows store, but I'm not entirely certain about that.

Another issue I found is that opening up a new tab inherits the environmental variables from the initial Terminal process, so it won't contain the latest ENV values. For example, after the pm2-installer setup completes, it requests that you start a new terminal session with the latest machine-level environmental variables before invoking pm2. If you open a new tab instead of a completely new Terminal window, the new tab will be loaded with the ENV values from before the setup ran and pm2 won't be able to read the $env:PM2_HOME value.

Regardless of these minor roadblocks, I'm very excited about Windows Terminal and can't wait for it to ship standard in Windows.

Glad to hear everything is working for you now! Hope this was helpful anyway.