Skip to content
Advertisement

Node JS process running under PM2 and file permissions

I have a small node.js (v13.5.0) server running under PM2 (v4.4.0) on a RHEL 7.6 box. As a part of it’s function it writes a small CSV file to the disc for every incoming request. This app is writing these files with the perms (rw-r—–).

The user I am having PM2 executing my process as has umask set to 0022. I have confirmed this is effective as it works in other cases.

So the main problem is that I cannot get my pm2+node combo to use the umask to write files with the right permissions.

Any suggestions where i am going wrong?

Thanks in advance,

Advertisement

Answer

So using ps fu -u $USER i figured out that PM2 daemon process had been running since i first started it (started column) – which was way before I made the umask change. As a result it was running with an outdated environment.

I restarted it using pm2 kill && pm2 start && pm2 ping which should return a pong. Subsequent tests proved that this had fixed the issue.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement