xtunnel 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +8 -11
- package/package.json +1 -1
package/index.js
CHANGED
@@ -9,11 +9,11 @@ const config = JSON.parse(fs.readFileSync(path.join(__dirname, './config/default
|
|
9
9
|
|
10
10
|
let rayProcess = null
|
11
11
|
|
12
|
-
process.on('exit',
|
13
|
-
process.on('SIGINT',
|
14
|
-
process.on('SIGUSR1',
|
15
|
-
process.on('SIGUSR2',
|
16
|
-
process.on('uncaughtException', err => { stop()
|
12
|
+
process.on('exit', stop)
|
13
|
+
process.on('SIGINT', stop)
|
14
|
+
process.on('SIGUSR1', stop)
|
15
|
+
process.on('SIGUSR2', stop)
|
16
|
+
process.on('uncaughtException', err => { stop(); process.exit(1) })
|
17
17
|
|
18
18
|
program.version('1.0.0').description('Tunnel CLI')
|
19
19
|
program.command('* <url>').action(url => url && run(url))
|
@@ -44,21 +44,18 @@ function start() {
|
|
44
44
|
// 设置系统代理
|
45
45
|
setSystemProxy(config.setting.localHttpPort)
|
46
46
|
// 根据操作系统平台-启动新进程
|
47
|
-
rayProcess = child_process.exec(path.join(__dirname, './core/xray-linux-x64'), (error, stdout, stderr) => error && stop(
|
47
|
+
rayProcess = child_process.exec(path.join(__dirname, './core/xray-linux-x64'), (error, stdout, stderr) => error && stop())
|
48
48
|
rayProcess.stdout.on('data', console.log)
|
49
49
|
rayProcess.stderr.on('data', console.error)
|
50
50
|
}
|
51
51
|
|
52
|
-
function stop(
|
52
|
+
function stop() {
|
53
53
|
console.log('TUNNEL STOP')
|
54
54
|
// 关闭上个进程
|
55
55
|
rayProcess && rayProcess.kill('SIGINT')
|
56
56
|
// 取消系统代理
|
57
57
|
setSystemProxy()
|
58
|
-
|
59
|
-
console.error('启动失败(请检查权限/端口占用),重新启动中...')
|
60
|
-
start()
|
61
|
-
}
|
58
|
+
process.exit(1)
|
62
59
|
return true
|
63
60
|
}
|
64
61
|
|