mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
Move initPM2 to CLI.js #712
This commit is contained in:
parent
02d47e8e60
commit
13c66ab2a0
32
bin/pm2
32
bin/pm2
@ -16,34 +16,7 @@ var CLI = require('../lib/CLI');
|
||||
var cst = require('../constants.js');
|
||||
var pkg = require('../package.json');
|
||||
|
||||
//
|
||||
// Init
|
||||
//
|
||||
(function init() {
|
||||
var exist = fs.existsSync(cst.DEFAULT_FILE_PATH);
|
||||
|
||||
if (!exist) {
|
||||
console.log('Initializing folder for pm2 on %s', cst.DEFAULT_FILE_PATH);
|
||||
fs.mkdirSync(cst.DEFAULT_FILE_PATH);
|
||||
fs.mkdirSync(cst.DEFAULT_LOG_PATH);
|
||||
fs.mkdirSync(cst.DEFAULT_PID_PATH);
|
||||
|
||||
/**
|
||||
* Create configuration file if not present
|
||||
*/
|
||||
fs.exists(cst.PM2_CONF_FILE, function(exist) {
|
||||
if (!exist) {
|
||||
console.log('Creating PM2 configuration file in %s', cst.PM2_CONF_FILE);
|
||||
fs
|
||||
.createReadStream(path.join(__dirname, cst.SAMPLE_CONF_FILE))
|
||||
.pipe(fs.createWriteStream(cst.PM2_CONF_FILE));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
CLI.pm2Init();
|
||||
|
||||
commander.version(pkg.version)
|
||||
.option('-v --version', 'get version')
|
||||
@ -132,8 +105,7 @@ function beginCommandProcessing() {
|
||||
console.log('Local PM2 version:', chalk.blue.bold(pkg.version));
|
||||
console.log('');
|
||||
}
|
||||
commander.parse(process.argv);
|
||||
|
||||
commander.parse(process.argv);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
23
lib/CLI.js
23
lib/CLI.js
@ -26,6 +26,29 @@ var printOut = Common.printOut;
|
||||
|
||||
var pm2 = require('..');
|
||||
|
||||
CLI.pm2Init = function() {
|
||||
var exist = fs.existsSync(cst.DEFAULT_FILE_PATH);
|
||||
|
||||
if (!exist) {
|
||||
console.log('Initializing PM2 configuration (%s)', cst.DEFAULT_FILE_PATH);
|
||||
fs.mkdirSync(cst.DEFAULT_FILE_PATH);
|
||||
fs.mkdirSync(cst.DEFAULT_LOG_PATH);
|
||||
fs.mkdirSync(cst.DEFAULT_PID_PATH);
|
||||
|
||||
/**
|
||||
* Create configuration file if not present
|
||||
*/
|
||||
fs.exists(cst.PM2_CONF_FILE, function(exist) {
|
||||
if (!exist) {
|
||||
fs
|
||||
.createReadStream(path.join(__dirname, cst.SAMPLE_CONF_FILE))
|
||||
.pipe(fs.createWriteStream(cst.PM2_CONF_FILE));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Method to start a script
|
||||
* @method startFile
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user