-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into development
- Loading branch information
Showing
171 changed files
with
2,447 additions
and
501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
# PM2 API | ||
|
||
Here is an example of the PM2 API: | ||
|
||
``` | ||
$ node api.js | ||
``` | ||
|
||
Will delete all apps, will start http.js, and restart http | ||
|
||
Then you will see that the listing shows http app, restarted one time: | ||
|
||
``` | ||
$ pm2 list | ||
┌──────────┬────┬──────┬──────┬────────┬─────────┬────────┬─────┬───────────┬─────────┬──────────┐ | ||
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │ | ||
├──────────┼────┼──────┼──────┼────────┼─────────┼────────┼─────┼───────────┼─────────┼──────────┤ | ||
│ http │ 0 │ fork │ 7668 │ online │ 1 │ 2s │ 0% │ 34.2 MB │ unitech │ disabled │ | ||
└──────────┴────┴──────┴──────┴────────┴─────────┴────────┴─────┴───────────┴─────────┴──────────┘ | ||
Use `pm2 show <id|name>` to get more details about an app | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
|
||
var pm2 = require('../..'); | ||
|
||
pm2.delete('all', function(err) { | ||
if (err) { | ||
console.error(err); | ||
return pm2.disconnect(); | ||
} | ||
|
||
pm2.start('http.js', function(err, app) { | ||
if (err) { | ||
console.error(err); | ||
return pm2.disconnect(); | ||
} | ||
|
||
console.log('Process HTTP has been started'); | ||
|
||
pm2.restart('http', function(err, app) { | ||
if (err) { | ||
console.error(err); | ||
return pm2.disconnect(); | ||
} | ||
|
||
console.log('Process Restarted'); | ||
return pm2.disconnect(); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
To start http application in cluster mode: | ||
|
||
```bash | ||
$ pm2 start ecosystem.config.js | ||
# OR | ||
$ pm2 start http.js -i max | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = { | ||
apps : [{ | ||
name : 'clustered_http', | ||
script : './http.js', | ||
instances : 'max', | ||
exec_mode : 'cluster', | ||
env : { | ||
PORT : 8002 | ||
} | ||
}, { | ||
name : 'forked_app', | ||
script : './http.js', | ||
env : { | ||
PORT : 8001 | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
To start tcp application in cluster mode: | ||
|
||
```bash | ||
$ pm2 start ecosystem.config.js | ||
# OR | ||
$ pm2 start tcp.js -i max | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
var http = require('http'); | ||
|
||
var server = http.createServer(function(req, res) { | ||
res.writeHead(200); | ||
res.end('hey'); | ||
}).listen(process.env.PORT || 8000, function() { | ||
console.log('App listening on port %d', server.address().port); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = { | ||
apps : [{ | ||
name : 'clustered_tcp', | ||
script : './tcp.js', | ||
instances : 'max', | ||
exec_mode : 'cluster', | ||
env : { | ||
PORT : 8002 | ||
} | ||
}, { | ||
name : 'forked_tcp', | ||
script : './tcp.js', | ||
env : { | ||
PORT : 8001 | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
Here we have 3 applications (apps folder) that we can start with process file. | ||
These process file can be of different format, javascript, json or yaml: | ||
|
||
``` | ||
. | ||
├── apps | ||
│ ├── connection_check.sh | ||
│ ├── http.js | ||
│ └── worker.js | ||
├── process.config.js | ||
├── process.json | ||
└── process.yml | ||
``` | ||
|
||
To start them: | ||
|
||
```bash | ||
$ pm2 start process.config.js | ||
$ pm2 delete all | ||
$ pm2 start process.json | ||
$ pm2 delete all | ||
$ pm2 start process.yml | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.