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

Install module crash in safe mode when file used #3669

Closed
f-hj opened this issue May 16, 2018 · 0 comments
Closed

Install module crash in safe mode when file used #3669

f-hj opened this issue May 16, 2018 · 0 comments

Comments

@f-hj
Copy link
Contributor

f-hj commented May 16, 2018

What's going wrong?

Safe install module doesn't work if file is used

How could we reproduce this issue?

pm2 install myModule when NPM servers are broken
https://status.npmjs.org/incidents/rmv88ktdgkkr

Supporting information

If NPM servers crash, we lost the module

root@envision-7d22e90d1977:~# PM2_HOME=/etc/pm2 pm2 install myModule
[PM2][Module] Installing module myModule
[PM2][Module] Module already installed. Updating.
rm: could not remove directory (code ENOTEMPTY): /etc/pm2/modules/myModule/node_modules/electron/dist
rm: could not remove directory (code ENOTEMPTY): /etc/pm2/modules/myModule/node_modules/electron
rm: could not remove directory (code ENOTEMPTY): /etc/pm2/modules/myModule/node_modules
rm: could not remove directory (code ENOTEMPTY): /etc/pm2/modules/myModule
[PM2][Module] Calling [NPM] to install myModule ...
npm ERR! Unexpected end of JSON input while parsing near '..."integrity":"sha512-H'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/root/.npm/_logs/2018-05-16T13_53_28_798Z-debug.log
[PM2][Module] [[[[[ Module installation failure! ]]]]]
[PM2][Module] [RESTORING TO PREVIOUS VERSION]
rm: could not remove directory (code ENOTEMPTY): /etc/pm2/modules/myModule/node_modules/electron/dist
rm: could not remove directory (code ENOTEMPTY): /etc/pm2/modules/myModule/node_modules/electron
rm: could not remove directory (code ENOTEMPTY): /etc/pm2/modules/myModule/node_modules
rm: could not remove directory (code ENOTEMPTY): /etc/pm2/modules/myModule
module.js:540
    throw err;
    ^

Error: Cannot find module '/etc/pm2/modules/myModule/node_modules/myModule/package.json'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (/usr/lib/node_modules/pm2/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at startModule (/usr/lib/node_modules/pm2/lib/API/Modules/Modularizer.js:268:22)
    at /usr/lib/node_modules/pm2/lib/API/Modules/Modularizer.js:406:7
    at /usr/lib/node_modules/pm2/lib/API/Modules/Modules.js:184:16
    at /usr/lib/node_modules/pm2/lib/Client.js:648:12
    at /usr/lib/node_modules/pm2/node_modules/pm2-axon-rpc/lib/client.js:45:10
    at Parser.<anonymous> (/usr/lib/node_modules/pm2/node_modules/pm2-axon/lib/sockets/req.js:67:8)
root@envision-7d22e90d1977:~# cat /etc/pm2/pm2.log
2018-05-16 06:21:04: ===============================================================================
2018-05-16 06:21:04: --- New PM2 Daemon started ----------------------------------------------------
2018-05-16 06:21:04: Time                 : Wed May 16 2018 06:21:04 GMT+0000 (UTC)
2018-05-16 06:21:04: PM2 version          : 2.9.2-next
2018-05-16 06:21:04: Node.js version      : 8.9.4
2018-05-16 06:21:04: Current arch         : x64
2018-05-16 06:21:04: PM2 home             : /etc/pm2
2018-05-16 06:21:04: PM2 PID file         : /etc/pm2/pm2.pid
2018-05-16 06:21:04: RPC socket file      : /etc/pm2/rpc.sock
2018-05-16 06:21:04: BUS socket file      : /etc/pm2/pub.sock
2018-05-16 06:21:04: Application log path : /etc/pm2/logs
2018-05-16 06:21:04: Process dump file    : /etc/pm2/dump.pm2
2018-05-16 06:21:04: Concurrent actions   : 2
2018-05-16 06:21:04: SIGTERM timeout      : 1600
2018-05-16 06:21:04: ===============================================================================
2018-05-16 06:21:08: Starting execution sequence in -fork mode- for app name:myModule id:0
2018-05-16 06:21:08: App name:myModule id:0 online
2018-05-16 06:21:09: Error while getting CLK_TCK { Error: Command failed: getconf CLK_TCK
/bin/sh: getconf: command not found

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:554:12) killed: false, code: 127, signal: null, cmd: 'getconf CLK_TCK' }
2018-05-16 06:21:09: Error while getting PAGESIZE { Error: Command failed: getconf PAGESIZE
/bin/sh: getconf: command not found

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:554:12)
  killed: false,
  code: 127,
  signal: null,
  cmd: 'getconf PAGESIZE' }
2018-05-16 13:31:30: Stopping app:myModule id:0
2018-05-16 13:31:30: App [myModule] with id [0] and pid [513], exited with code [1] via signal [SIGINT]
2018-05-16 13:31:30: pid=513 msg=process killed

and PM2 safe mode doesn't work as expected

Solution?

  • Correct safe mode to ignore ENOTEMPTY when install fail?
  • Make npm cache clean --force with manual install solved the problem
@f-hj f-hj mentioned this issue Jun 25, 2018
wallet77 added a commit that referenced this issue Jun 25, 2018
inerc pushed a commit to inerc/pm2 that referenced this issue Feb 11, 2020
Fix revert path of modules
inerc pushed a commit to inerc/pm2 that referenced this issue Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant