• R/O
  • HTTP
  • SSH
  • HTTPS

bytom-electron: 提交

Bytom Desktop Electron App


Commit MetaInfo

修订版bcccd0c2aff77d5fc73c8c6ed3fef2d415679604 (tree)
时间2019-10-28 10:54:26
作者Zhiting Lin <zlin035@uott...>
CommiterZhiting Lin

Log Message

update the port retry logic

更改概述

差异

--- a/main.js
+++ b/main.js
@@ -11,7 +11,7 @@ const log = logger.create('main')
1111 const bytomdLog = logger.create('bytomd')
1212 const Settings = require('./modules/settings')
1313
14-const net = require('net')
14+const tcpPortUsed = require('tcp-port-used');
1515
1616 let win, bytomdInit, bytomdNode
1717
@@ -119,8 +119,14 @@ function setBytomNode(event) {
119119 })
120120
121121 bytomdNode.stderr.on('data', function(data) {
122- bytomdLog.info(`bytomd node: ${data}`)
123- if (data.includes('msg="start node')) {
122+ bytomdNode.on('exit', function (code) {
123+ bytomdLog.info('bytom Node exited with code ' + code)
124+ app.quit()
125+ })
126+ })
127+
128+ tcpPortUsed.waitUntilUsed(9888, 500, 20000)
129+ .then(function() {
124130 if (event) {
125131 event.sender.send('ConfiguredNetwork', 'startNode')
126132 }
@@ -128,13 +134,9 @@ function setBytomNode(event) {
128134 startnode = true
129135 win.webContents.send('ConfiguredNetwork', 'startNode')
130136 }
131- }
132-
133- bytomdNode.on('exit', function (code) {
134- bytomdLog.info('bytom Node exited with code ' + code)
135- app.quit()
136- })
137- })
137+ }, function(err) {
138+ bytomdLog.info('Error:', err.message);
139+ });
138140 }
139141
140142 function setBytomInit(event, bytomNetwork) {
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
11 {
22 "name": "bytom-wallet",
3- "version": "1.0.9",
3+ "version": "1.0.10",
44 "lockfileVersion": 1,
55 "requires": true,
66 "dependencies": {
@@ -2601,8 +2601,7 @@
26012601 "deep-is": {
26022602 "version": "0.1.3",
26032603 "resolved": "http://registry.npm.taobao.org/deep-is/download/deep-is-0.1.3.tgz",
2604- "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=",
2605- "dev": true
2604+ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ="
26062605 },
26072606 "define-properties": {
26082607 "version": "1.1.2",
@@ -5366,6 +5365,11 @@
53665365 "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=",
53675366 "dev": true
53685367 },
5368+ "ip-regex": {
5369+ "version": "2.1.0",
5370+ "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz",
5371+ "integrity": "sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk="
5372+ },
53695373 "ipaddr.js": {
53705374 "version": "1.6.0",
53715375 "resolved": "http://registry.npm.taobao.org/ipaddr.js/download/ipaddr.js-1.6.0.tgz",
@@ -5620,12 +5624,27 @@
56205624 "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
56215625 "dev": true
56225626 },
5627+ "is-url": {
5628+ "version": "1.2.4",
5629+ "resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz",
5630+ "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww=="
5631+ },
56235632 "is-utf8": {
56245633 "version": "0.2.1",
56255634 "resolved": "http://registry.npm.taobao.org/is-utf8/download/is-utf8-0.2.1.tgz",
56265635 "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=",
56275636 "dev": true
56285637 },
5638+ "is2": {
5639+ "version": "2.0.1",
5640+ "resolved": "https://registry.npmjs.org/is2/-/is2-2.0.1.tgz",
5641+ "integrity": "sha512-+WaJvnaA7aJySz2q/8sLjMb2Mw14KTplHmSwcSpZ/fWJPkUmqw3YTzSWbPJ7OAwRvdYTWF2Wg+yYJ1AdP5Z8CA==",
5642+ "requires": {
5643+ "deep-is": "0.1.3",
5644+ "ip-regex": "2.1.0",
5645+ "is-url": "1.2.4"
5646+ }
5647+ },
56295648 "isarray": {
56305649 "version": "0.0.1",
56315650 "resolved": "http://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz",
@@ -6402,6 +6421,11 @@
64026421 "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==",
64036422 "dev": true
64046423 },
6424+ "net": {
6425+ "version": "1.0.2",
6426+ "resolved": "https://registry.npmjs.org/net/-/net-1.0.2.tgz",
6427+ "integrity": "sha1-0XV+yaf7I3HYPPR1XOPifhCCk4g="
6428+ },
64056429 "nice-try": {
64066430 "version": "1.0.4",
64076431 "resolved": "http://registry.npm.taobao.org/nice-try/download/nice-try-1.0.4.tgz",
@@ -10461,6 +10485,30 @@
1046110485 "inherits": "2.0.3"
1046210486 }
1046310487 },
10488+ "tcp-port-used": {
10489+ "version": "1.0.1",
10490+ "resolved": "https://registry.npmjs.org/tcp-port-used/-/tcp-port-used-1.0.1.tgz",
10491+ "integrity": "sha512-rwi5xJeU6utXoEIiMvVBMc9eJ2/ofzB+7nLOdnZuFTmNCLqRiQh2sMG9MqCxHU/69VC/Fwp5dV9306Qd54ll1Q==",
10492+ "requires": {
10493+ "debug": "4.1.0",
10494+ "is2": "2.0.1"
10495+ },
10496+ "dependencies": {
10497+ "debug": {
10498+ "version": "4.1.0",
10499+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz",
10500+ "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==",
10501+ "requires": {
10502+ "ms": "2.1.2"
10503+ }
10504+ },
10505+ "ms": {
10506+ "version": "2.1.2",
10507+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
10508+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
10509+ }
10510+ }
10511+ },
1046410512 "temp-file": {
1046510513 "version": "3.1.2",
1046610514 "resolved": "http://registry.npm.taobao.org/temp-file/download/temp-file-3.1.2.tgz",
--- a/package.json
+++ b/package.json
@@ -97,8 +97,9 @@
9797 "glob": "~7.1.2",
9898 "i18next": "^11.9.1",
9999 "i18next-browser-languagedetector": "^2.2.3",
100- "log4js": "^3.0.5",
101100 "lodash": "~4.17.14",
101+ "log4js": "^3.0.5",
102+ "net": "^1.0.2",
102103 "moment": "^2.22.1",
103104 "moment-timezone": "^0.5.17",
104105 "pluralize": "~3.0.0",
@@ -121,6 +122,7 @@
121122 "redux-thunk": "~2.1.0",
122123 "reselect": "^3.0.0",
123124 "sha.js": "^2.4.8",
125+ "tcp-port-used": "^1.0.1",
124126 "toml": "~2.3.3",
125127 "uuid": "~2.0.2"
126128 },
Show on old repository browser