Search code examples
node.jsprocessforkuid

Fork a worker under different user with Node.js cluster module?


How to fork a worker under different user with Node.js cluster module?


Solution

  • It can be done by populating cluster.settings object with uid property in master process. In my case it looks like this:

    cluster.settings.uid = 10000;
    

    where 10000 is my uid

    To get your uid on Linux, run:

    id -u <your-user-name-here>
    

    or simply:

    id -u