pinokiod 3.15.21 → 3.15.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/kernel/index.js CHANGED
@@ -812,7 +812,7 @@ class Kernel {
812
812
  if (network_active) {
813
813
  this.refresh_interval = setInterval(() => {
814
814
  if (this.server_running) {
815
- this.refresh()
815
+ this.refresh(true)
816
816
  } else {
817
817
  console.log("server not running yet. retry network refresh in 5 secs")
818
818
  }
package/kernel/procs.js CHANGED
@@ -15,10 +15,12 @@ class Procs {
15
15
  }
16
16
  async isHttp(localAddress) {
17
17
  if (this.cache.hasOwnProperty(localAddress)) {
18
+ console.log("Use cached", localAddress)
18
19
  return this.cache[localAddress]
19
20
  }
21
+ console.log("Not cached", localAddress)
20
22
  try {
21
- await axios.head(`http://${localAddress}`, { timeout: 1000 });
23
+ await axios.head(`http://${localAddress}`, { timeout: 3000 });
22
24
  this.cache[localAddress] = true
23
25
  return true;
24
26
  } catch (err) {
@@ -46,7 +48,7 @@ class Procs {
46
48
  let pids = new Set()
47
49
  let s = stdout.trim()
48
50
  const lines = s.split('\n');
49
- console.time("###### Line parsing")
51
+ // console.time("###### Line parsing")
50
52
  for(let line of lines) {
51
53
  if (isWin) {
52
54
  // Skip headers
@@ -119,15 +121,14 @@ class Procs {
119
121
  }
120
122
  }
121
123
  }
122
- console.timeEnd("###### Line parsing")
123
- console.time("########## http_check")
124
+ // console.timeEnd("###### Line parsing")
125
+ // console.time("########## http_check")
124
126
  const http_check = await Promise.all(results.map(({ ip }) => {
125
127
  return limit(() => {
126
128
  return this.isHttp(ip)
127
129
  })
128
130
  }))
129
- console.timeEnd("########## http_check")
130
- console.log({ http_check })
131
+ // console.timeEnd("########## http_check")
131
132
  let filtered = []
132
133
  for(let i=0; i<http_check.length; i++) {
133
134
  if (http_check[i]) {
@@ -240,7 +241,12 @@ class Procs {
240
241
  // console.log("GET MAP")
241
242
  this.pid_running = false
242
243
  let map = this.get_name(e.state)
243
- this.port_map = map
244
+ if (!this.port_map) {
245
+ this.port_map = {}
246
+ }
247
+ for(let key in map) {
248
+ this.port_map[key] = map[key]
249
+ }
244
250
  this.pid_cb(map)
245
251
  }
246
252
  }
@@ -251,26 +257,25 @@ class Procs {
251
257
  }
252
258
  }
253
259
  async refresh() {
254
- console.log("Procs.refresh")
255
260
  let map = {}
256
261
  this.refreshing = true
257
262
  let ts = Date.now()
258
263
  let list = await new Promise((resolve, reject) => {
259
- console.time(">>>>>>>>GET PORTS " + ts)
260
- console.log("get ports")
264
+ // console.time(">>>>>>>>GET PORTS " + ts)
265
+ // console.log("get ports")
261
266
  this.getPortPidList((portPidList) => {
262
- console.log("done: get ports")
263
- console.log({ portPidList })
264
- console.timeEnd(">>>>>>>>GET PORTS " + ts)
265
- console.time(">>>>>>> GET PIDS " + ts)
267
+ // console.log("done: get ports")
268
+ // console.log({ portPidList })
269
+ // console.timeEnd(">>>>>>>>GET PORTS " + ts)
270
+ // console.time(">>>>>>> GET PIDS " + ts)
266
271
  // if there's any new port, run getPidToNameMap
267
272
 
268
273
 
269
- console.log("getPid")
274
+ // console.log("getPid")
270
275
  this.getPidToNameMap(portPidList, (pidToName) => {
271
- console.log("done getPid")
276
+ // console.log("done getPid")
272
277
 
273
- console.timeEnd(">>>>>>> GET PIDS " + ts)
278
+ // console.timeEnd(">>>>>>> GET PIDS " + ts)
274
279
  let list = portPidList.map(({ port, pid, ip }) => {
275
280
  const fullname = pidToName[pid] || 'Unknown';
276
281
  const name = fullname.split(path.sep).pop()
@@ -208,9 +208,9 @@ class Router {
208
208
  // update caddy config
209
209
  async update() {
210
210
  if (JSON.stringify(this.config) === JSON.stringify(this.old_config)) {
211
- // console.log("config hasn't updated")
211
+ console.log("######### config hasn't updated")
212
212
  } else {
213
- // console.log("caddy config has updated", this.config)
213
+ console.log("######### caddy config has updated. refresh", this.config)
214
214
  try {
215
215
  let response = await axios.post('http://127.0.0.1:2019/load', this.config, {
216
216
  headers: { 'Content-Type': 'application/json' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.15.21",
3
+ "version": "3.15.23",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {