(CLI) pm2 ecosystem simple

This commit is contained in:
Unitech 2017-01-29 13:33:26 +01:00
parent d11bb7f31a
commit 683c1ea50b
5 changed files with 20 additions and 11 deletions

View File

@ -3,6 +3,7 @@
- #2670 allow to expose a folder via `pm2 server <path> -p <port>`
- #2617 fix startup script generation on macosx (launchd)
- #2650 new option to append env name to app name (used to allow the same app to be launched in different environement w/o name conflict)
- `pm2 ecosystem simple` to generate a simple ecosystem file
- aliasing: `pm2-dev <script>` <=> `pm2-dev start <script>`
- allow to pass a delay to pm2-docker (`pm2-docker process.json --delay 10`)

14
bin/pm2
View File

@ -582,16 +582,12 @@ commander.command('logrotate')
//
// Sample generate
//
commander.command('generate')
.description('generate an ecosystem.json configuration file')
.action(function(name) {
pm2.generateSample(name);
});
commander.command('ecosystem')
.description('generate an ecosystem.json configuration file')
.action(function(name) {
pm2.generateSample(name);
commander.command('ecosystem [mode]')
.alias('generate')
.description('generate a process conf file. (mode = null or simple)')
.action(function(mode) {
pm2.generateSample(mode);
});
commander.command('reset <name|id|all>')

View File

@ -29,6 +29,7 @@ var csts = {
TEMPLATE_FOLDER : p.join(__dirname, 'lib/templates'),
APP_CONF_TPL : 'ecosystem.tpl',
APP_CONF_TPL_SIMPLE : 'ecosystem-simple.tpl',
SAMPLE_CONF_FILE : 'sample-conf.js',
LOGROTATE_SCRIPT : 'logrotate.d/pm2',

View File

@ -309,10 +309,14 @@ module.exports = function(CLI) {
* @param {} name
* @return
*/
CLI.prototype.generateSample = function() {
CLI.prototype.generateSample = function(mode) {
var that = this;
var templatePath;
var templatePath = path.join(cst.TEMPLATE_FOLDER, cst.APP_CONF_TPL);
if (mode == 'simple')
templatePath = path.join(cst.TEMPLATE_FOLDER, cst.APP_CONF_TPL_SIMPLE);
else
templatePath = path.join(cst.TEMPLATE_FOLDER, cst.APP_CONF_TPL);
var sample = fs.readFileSync(templatePath);
var dt = sample.toString();
@ -323,6 +327,7 @@ module.exports = function(CLI) {
fs.writeFileSync(path.join(pwd, f_name), dt);
} catch (e) {
console.error(e.stack || e);
return that.exitCli(cst.ERROR_EXIT);
}
Common.printOut('File %s generated', path.join(pwd, f_name));
that.exitCli(cst.SUCCESS_EXIT);

View File

@ -0,0 +1,6 @@
module.exports = {
apps : [{
name : "app1",
script : "./app.js"
}]
}