Search code examples
javascriptconfigpm2

Modify the "exec cwd" path of the process -PM2


I have multiple processes that run on the server.

  • Each of the processes is placed in it's own directory.
  • All of them are controlled by PM2
  • Each process is supposed to have config and ecosystem files within their folders
  • Root folder is supposed to be empty and not related to any processes.

One process that was set up incorrectly. I had to make it work (without touching things that do) so for this process :

  • Pm2 show (id) indicated that the exec cwd is running from root so:
  • Copy essential folders and files of the root folder
  • Config folder, logs, other essentials had to be copied

I would like to redirect the process from root to its own folder. It seems I can do it simply by modifying the exec cwd but I don't know how to do it.

Please help :) Cheers


Solution

  • Ok well.

    It seems it is impossible to modify it like this as this functionality is not implemented.

    Therefore:

    • copy ecosystem and what you need from folder you are in to where you want it to run from
    • delete the process completely
    • do cd {path to your desired directory}
    • pm2 start ecosystem.config.js

    //Additional if you want to keep the process old Id

    • pm2 kill (deletes all processes)
    • pm2 resurrect (restores them all with original id's)