I just installed pm2 (on Debian 9) and I need to run NodeJS server of few users. Every user have own NodeJS server what I need to run under them. Not under root.
For example I have user "user1":
pm2 startup
pm2 still works on user1, but after restart I cannot control pm2 and Iam getting this error:
[PM2][ERROR] Permission denied, to give access to current user:
$ sudo chown user1:user1 /home/user1/.pm2/rpc.sock /home/user1/.pm2/pub.sock
If I execute this command on root, I can then again control pm2 on user1, but all NodeJS servers are executed as root!!
I need to 'grant' permissions every restart..
How to fix this?
I found myself why it not work. My user names are with dot (domain.com) and systemd not recognised this as valid user name... Because that service started under root.
Quick fix is to find auto-generated service in systemd and replace user name with user id found by id -u <user>