node.jsnamespacesqueuepm2worker

What is PM2 namespace?


I have tens of processes and all of them have 'default' as their namespace.

When I run pm2 show processid it returns:

│ status            │ online                                      │
│ name              │ Email Worker 1                              │
│ namespace         │ default                                     │
│ version           │ N/A                                         │
│ restarts          │ 2                                           │
│ uptime            │ 21h                                         │
│ script path       │ /bin/bash

But I don't know what the namespace is and how to change/use it. I looked at the official documentation but still not found any info about it?

Is it like a group of processes? But how to set and use it?


Solution

  • Namespace is a grouping of processes running on pm2.

    For more information on how to use namespace, see the

    pm2 start [processName] --name [name] --namespace [namespace]
    

    You can run it with the command in .

    The basic method of utilization is You can view logs from the same group at once.

    Usually when viewing pm2 logs

    pm2 log [name]
    

    You can see it as

    If you're using a namespace to group

    pm2 log [namespace] 
    

    allows you to view the logs for that group at once.

    You can also use that namespace to start/end.

    pm2 start [namespace]
    pm2 stop [namespace]
    pm2 restart [namespace]