Pm2: Feature request: Renaming Apps

Created on 27 Oct 2013  路  12Comments  路  Source: Unitech/pm2

Hey,
I think it would be pretty neat to have a action to renaming processes by there ID to something else

Most helpful comment

On next release 1.0.3:

$ pm2 restart app --name "new-name"

All 12 comments

you can do pm2 delete myoldappname ; pm2 start app.js --name newname

Maybe have default App name be the name of the folder if the file being run is app.js rather than "app" or offer a built-in method of renaming entries without losing the data related to the old name of the application.

I'm using pm2 to manage my development environment and I also wish for this feature...
Example:

cd project1
pm2 http-server -- -c-1 build/www
pm2 proxy -n "backend-proxy"

# a few days later,
# I need to work on project2 with a similar setup,
# so I wanted to do something like this
pm2 rename http-server -n project1-http-server
pm2 rename backend-proxy -n project1-backend-proxy

# stopping so I can switch back to project1 later
pm2 stop project1-http-server
pm2 stop project1-backend-proxy

cd project2
pm2 http-server -n project2-http-proxy -- -c-1 build/www
pm2 proxy -n "project2-backend-proxy"

Right now, instead of pm2 rename ..., I would have delete the existing processes and re-create them, which takes more time...
...of course taking the time to come here and write this, took even more time.... damn :)

This would be nice to have. Deleting the app and starting it again removes the restart stats and creates a new id.

I agree. Just ran into the same problem. I would like to have it keep the same process id.

Same here

@Unitech wrote:

you can do pm2 delete myoldappname ; pm2 start app.js --name newname

Talking about 0-downtime it would mean not 0-downtime. :wink: From the other point, renaming apps on production is not something we do everyday. You do not name apps by day name, right guys :smile:? So I think this feature is not something super-important.

Other important feature would be taking into account changed JSON declaration during reload / gracefulReload (I recall there is an issue already for this). So guys with "renaming problem" would have to just change their JSON declaration and reload app.

On next release 1.0.3:

$ pm2 restart app --name "new-name"

Update available ([email protected] - latest stable):

$ npm install pm2@latest -g
$ pm2 update

Please re-open this issue if you notice any problem,

The "restart" command above doesn't work on my pm2(ver 2.2.3). I have to rename the app with this command.

pm2 restart app --name "new-name" --update-env

@Unitech Hello.I am using pm2 module in my electron app.How can I rename an app using the restart command?I have tried the following

pm2.restart({
    app:"Old name",
    name:"New name"
},(err)=>{
    if(!err) console.log('App has been renamed')
   else console.log('Failed')
});

It will log that App has been renamed but if I do pm2 list in the cli I see that my app has not be renamed.
Is it possible to rename an app using the programmatic api?

pm2 restart id --name newName
It's the same as the above answers.
You can use the ID of the app to rename it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

liujb picture liujb  路  3Comments

lefam picture lefam  路  3Comments

webchaz picture webchaz  路  3Comments

psparago picture psparago  路  3Comments

alexpts picture alexpts  路  3Comments