-
Notifications
You must be signed in to change notification settings - Fork 2
/
amazing
executable file
·62 lines (50 loc) · 1.51 KB
/
amazing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env node
/**
* Module dependencies.
*/
var child_process = require('child_process'),
fs = require('fs'),
path = require('path'),
program = require('commander'),
tools = require('./tools');
var exec = child_process.exec,
conf = {
port: 9090
},
_port = '9090';
function setPort( val ){
conf.port = val;
}
function startServer(){
var root = path.resolve('./');
var port = conf.port;
var jarPath = path.resolve(__dirname + '/libs/server.jar');
var startSerCommond = 'java -jar "' + jarPath + '" --base ./ --root "' + root + '" --port ' + port;
console.log('* Server is starting , port is ' + port);
var server = exec(startSerCommond, function( err, stdout, stderr ){
if(err)
console.log('* 服务器启动失败!', err);
throw err;
console.log('* Congratulation, 服务器启动成功!');
console.log('* PID: ', server.pid)
})
setTimeout(function() {
console.log('* PID: ', server.pid);
}, 500);
}
function init() {
var webConfPath = path.resolve(__dirname + '/WEB-INF'),
targetPath = path.resolve('./WEB-INF');
if(!fs.existsSync( targetPath )){
tools.copy( webConfPath, targetPath)
}
}
program
.version('0.0.1')
.usage('[options] <file ...>')
.option('-i, --init', '初始化服务器的webapp环境', init)
.option('-p, --port <num>', '指定服务启动端口', setPort)
.parse(process.argv);
if(!program.init){
startServer();
}