I do have spawn eaccess error after i did the following command.
su www-data
pm2 -v
Error: spawn EACCES
at exports._errnoException (util.js:746:11)
at ChildProcess.spawn (child_process.js:1162:11)
at Object.exports.spawn (child_process.js:995:9)
at Object.launchDaemon (/usr/local/nvm/versions/node/v0.12.2/lib/node_modules/pm2/lib/Satan.js:346:40)
at /usr/local/nvm/versions/node/v0.12.2/lib/node_modules/pm2/lib/Satan.js:53:20
at /usr/local/nvm/versions/node/v0.12.2/lib/node_modules/pm2/lib/Satan.js:394:14
at process._tickDomainCallback (node.js:381:11)
[ctown@dolpin root]$ echo PM2_NODE_OPTIONS
Besides that, any step/guideline to run pm2 service as non-root user?
It seems like pm2 hasn't been installed as www-data. You have an EACCES error because pm2 doesn't have the correct permissions.
any idea how to install it and run it for different user?
Besides that, any step/guideline to run pm2 service as non-root user?
It's in the docs... pm2 startup ubuntu -u myUser will generate a startup file that launches pm2 as myUser
I run everything as non-root... Note you'll also need to make sure the pm2 binary is in a folder that the user has access to ..
Here's my Ansible script to set up PM2:
- name: Setting permissions of global node_modules folder
file: path=/usr/local/lib/node_modules state=directory owner=ubuntu group=ubuntu
sudo: true
- name: Setting permissions of local node_modules folder
file: path=/home/ubuntu/.npm state=directory owner=ubuntu group=ubuntu
sudo: true
- name: Adding nodejs repository
apt_repository: repo='ppa:chris-lea/node.js' state=present
sudo: true
- name: Installing nodejs
apt: pkg=nodejs state=installed
sudo: true
- name: add ~/bin to path for npm
lineinfile: dest=/etc/environment
state=present
backrefs=yes
regexp='PATH=(["]*)((?!.*?/home/ubuntu/bin).*?)(["]*)$'
line="PATH=\1\2:/home/ubuntu/bin\3"
sudo: true
- name: Setting npm prefix to ~
shell: npm config set prefix ~
- name: Installing n node module
shell: npm install -g n
sudo: true
- name: Upgrading nodejs to v0.12.2
shell: n 0.12.2
sudo: true
- name: Removing old nodejs binary
file: path=/usr/bin/nodejs state=absent
sudo: true
- name: Creating node/nodejs symlink
file: src=/usr/local/bin/node dest=/usr/local/bin/nodejs state=link
sudo: true
- name: Installing pm2 node module
shell: npm install -g pm2
- name: Setting up PM2 autostart
shell: /home/ubuntu/lib/node_modules/pm2/bin/pm2 startup ubuntu -u ubuntu
sudo: true
thanks for your guideline
@martingg88 Did you managed to get it to work again ? :)
yes..it work again after i reboot and clean all pm2 process.
However. i'm facing one issue that the dump file is deleted after reboot. so that i have to manually start pm2 after reboot. any idea?
After reboot when pm2 crashed or after every reboot ?
Actually when you reboot your machine, PM2 receives a SIGTERM signal and then dumps the actual list of apps running before exiting.
Any chance this list might be empty just moments before the reboot ?
I'm going to implement a safe system to prevent overriding the dump file with an empty list unless the user typed pm2 dump manually.
https://github.com/Unitech/PM2/commit/29ac39acc3611cbfda7f1d7ef2d624b9742c386a
Here we go.
npm i -g git://github.com/Unitech/PM2#development
I tried the following method in order .
dump file is no empty before reboot.
dump file become empty after reboot
pm2 start process
pm2 save
reboot
It shouldn't erase your dump file anymore on reboot with the latest commit above :)
thanks. i will try it and let you know the outcome..
many thanks guy
tried that development version and it still empty dump file after reboot
I have the same issue...
No permissions for the current directory
Switch to project directory
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
No permissions for the current directory
Switch to project directory