Unitech/pm2 — pull request #307 by sailxjx (2014-02-15 05:14:27+00:00)
Title: Restart by path? No, I really don't need it.

Hi, Alex:

`pm2 restart path|scriptname` command exists for a long time, recently I found some issues with this command, for example:

I have a node service (and others) named 'striker' on my server, the startup script is something like '/usr/local/repos/striker/bin/striker', and I deployed two version of this script, which one is 'release' versions and another is 'general availability' version.

When I start these two service with pm2, it works well.

```
┌────────────┬────┬─────────┬──────┬────────┬──────┬───────────┬────────┬───────────┬───────────────────────────────────────────────┐
│ App Name │ id │ mode │ PID │ status │ port │ Restarted │ Uptime │ memory │ err logs │
├────────────┼────┼─────────┼──────┼────────┼──────┼───────────┼────────┼───────────┼───────────────────────────────────────────────┤
│ striker-ga │ 0 │ cluster │ 6473 │ online │ │ 0 │ 3s │ 22.684 MB │ /Users/tristan/.pm2/logs/striker-ga-err-0.log │
├────────────┼────┼─────────┼──────┼────────┼──────┼───────────┼────────┼───────────┼───────────────────────────────────────────────┤
│ striker │ 1 │ cluster │ 6481 │ online │ │ 0 │ 0s │ 12.383 MB │ /Users/tristan/.pm2/logs/striker-err-1.log │
└────────────┴────┴─────────┴──────┴────────┴──────┴───────────┴────────┴───────────┴───────────────────────────────────────────────┘
```

When I restart the release version by name, `pm2 restart striker`, it will restart both two scripts unexpected.

```
┌────────────┬────┬─────────┬──────┬────────┬──────┬───────────┬────────┬───────────┬───────────────────────────────────────────────┐
│ App Name │ id │ mode │ PID │ status │ port │ Restarted │ Uptime │ memory │ err logs │
├────────────┼────┼─────────┼──────┼────────┼──────┼───────────┼────────┼───────────┼───────────────────────────────────────────────┤
│ striker-ga │ 0 │ cluster │ 6975 │ online │ │ 1 │ 0s │ 20.770 MB │ /Users/tristan/.pm2/logs/striker-ga-err-0.log │
├────────────┼────┼─────────┼──────┼────────┼──────┼───────────┼────────┼───────────┼───────────────────────────────────────────────┤
│ striker │ 1 │ cluster │ 6976 │ online │ │ 1 │ 0s │ 11.992 MB │ /Users/tristan/.pm2/logs/striker-err-1.log │
└────────────┴────┴─────────┴──────┴────────┴──────┴───────────┴────────┴───────────┴───────────────────────────────────────────────┘
```

I found this issue was caused by 'God/Methods.findByName' function. I wonder how many people will use `restart` command with path or script name. So I removed `find by path/script name` in `findByName` function, just keep it **simple** and **clear**. What's your opinion?

Cheers!