xtunnel 1.1.1 → 1.1.5

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