mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
(CLI) pm2 ecosystem simple
This commit is contained in:
parent
d11bb7f31a
commit
683c1ea50b
@ -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
14
bin/pm2
@ -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>')
|
||||
|
||||
@ -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',
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
6
lib/templates/ecosystem-simple.tpl
Normal file
6
lib/templates/ecosystem-simple.tpl
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
apps : [{
|
||||
name : "app1",
|
||||
script : "./app.js"
|
||||
}]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user