Skip to content

Commit 656d0bf

Browse files
committed
(pm2-docker) start option is now optional
1 parent 9d63fe9 commit 656d0bf

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

bin/pm2-docker

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,37 @@ commander.version(pkg.version)
2222
.option('--public [key]', 'keymetrics public key')
2323
.option('--machine-name [name]', 'keymetrics machine name')
2424
.option('--auto-exit', 'exit if all processes are errored/stopped or 0 apps launched')
25+
.option('--env [name]', 'select env_[name] env variables in process config file')
26+
.option('--watch', 'Watch and Restart')
2527
.usage('start <app>');
2628

29+
function start(cmd, opts) {
30+
pm2 = new PM2.custom({
31+
pm2_home : path.join(process.env.HOME, '.pm2'),
32+
secret_key : process.env.KEYMETRICS_SECRET || commander.secret,
33+
public_key : process.env.KEYMETRICS_PUBLIC || commander.public,
34+
machine_name : process.env.INSTANCE_NAME || commander.machineName,
35+
daemon_mode : true
36+
});
37+
38+
if (commander.autoExit)
39+
autoExit();
40+
41+
pm2.connect(function() {
42+
run(cmd, opts);
43+
});
44+
}
45+
2746
commander.command('*')
28-
.action(function(cmd, opts){
29-
console.error('Unknown command argument');
30-
commander.outputHelp();
47+
.action(function(cmd){
48+
start(cmd, commander);
3149
});
3250

3351
// @todo need to allow passing same option than pm2 start
3452
commander.command('start <file|json_file>')
35-
.option('--env [name]', 'select env_[name] env variables in process config file')
36-
.option('--watch', 'Watch and Restart')
3753
.description('start json_file or application')
38-
.action(function(cmd, opts) {
39-
40-
pm2 = new PM2.custom({
41-
pm2_home : path.join(process.env.HOME, '.pm2'),
42-
secret_key : process.env.KEYMETRICS_SECRET || commander.secret,
43-
public_key : process.env.KEYMETRICS_PUBLIC || commander.public,
44-
machine_name : process.env.INSTANCE_NAME || commander.machineName,
45-
daemon_mode : true
46-
});
47-
48-
if (commander.autoExit)
49-
autoExit();
50-
51-
pm2.connect(function() {
52-
run(cmd, opts);
53-
});
54+
.action(function(cmd) {
55+
start(cmd, commander);
5456
});
5557

5658
if (process.argv.length == 2) {

0 commit comments

Comments
 (0)