pinokiod 3.8.101 → 3.8.102

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/procs.js CHANGED
@@ -81,6 +81,7 @@ class Procs {
81
81
  }
82
82
  async refresh() {
83
83
  console.time("Get list")
84
+ let map = {}
84
85
  let list = await new Promise((resolve, reject) => {
85
86
  this.getPortPidList((err, portPidList) => {
86
87
  if (err) {
@@ -97,6 +98,7 @@ class Procs {
97
98
  let list = portPidList.map(({ port, pid, ip }) => {
98
99
  const fullname = pidToName[pid] || 'Unknown';
99
100
  const name = fullname.split(path.sep).pop()
101
+ map["" + pid] = fullname
100
102
  return { port, pid , name, fullname, ip }
101
103
  })
102
104
  list = list.filter((item) => {
@@ -108,6 +110,7 @@ class Procs {
108
110
  })
109
111
  console.timeEnd("Get list")
110
112
  this.info = list
113
+ this.map = map
111
114
  }
112
115
  }
113
116
  module.exports = Procs
@@ -4,7 +4,7 @@ class Connector {
4
4
  }
5
5
  handle ({ match, connector, dial, }) {
6
6
  console.log("connector.handle", { match, connector, dial })
7
- let connector_name = connector.host + ":" + connector.port
7
+ let connector_name = connector.host + "-" + connector.port
8
8
  let listener = "0.0.0.0:PORT_PLACEHOLDER_" + connector_name
9
9
  let listener_pointer = connector.host + ":PORT_PLACEHOLDER_" + connector_name
10
10
  if(!this.router.config.apps.http.servers[connector_name]) {
@@ -89,7 +89,7 @@ class Router {
89
89
  async fill() {
90
90
  const jsonString = JSON.stringify(this.config)
91
91
  // find all PORT_PLACEHOLDER patterns
92
- const matches = jsonString.match(/:PORT_PLACEHOLDER_[0-9.:]+/g)
92
+ const matches = jsonString.match(/:PORT_PLACEHOLDER_[0-9.-]+/g)
93
93
 
94
94
 
95
95
  // iterate through them and see if the port already exists
@@ -1,10 +1,11 @@
1
1
  const Common = require('./common')
2
- class LocalhostHomeRouter {
2
+ class LocalhostPortRouter {
3
3
  constructor(router) {
4
4
  this.router = router
5
5
  this.common = new Common(router)
6
6
  }
7
7
  handle (proc) {
8
+ console.log("LocalhostPortRouter", proc)
8
9
  this.common.handle({
9
10
  match: `${proc.port}.localhost`,
10
11
  dial: proc.ip,
@@ -12,4 +13,4 @@ class LocalhostHomeRouter {
12
13
  })
13
14
  }
14
15
  }
15
- module.exports = LocalhostHomeRouter
16
+ module.exports = LocalhostPortRouter
@@ -8,7 +8,7 @@ class LocalhostVariableRouter extends Processor {
8
8
  this.common = new Common(router)
9
9
  }
10
10
  handle (local) {
11
- console.log("localhost_variable_router", { local })
11
+ console.log("LocalhostVariableRouter", local)
12
12
  for(let script_path in local) {
13
13
  let local_variables_for_script = local[script_path]
14
14
  for(let key in local_variables_for_script) {
@@ -5,6 +5,7 @@ class PeerHomeRouter {
5
5
  this.common = new Common(router)
6
6
  }
7
7
  handle(peer) {
8
+ console.log("PeerHomeRouter", peer)
8
9
  this.common.handle({
9
10
  match: `${this.router.default_prefix}.${peer.name}.${this.router.default_suffix}`,
10
11
  dial: `${peer.host}:${this.router.default_port}`,
@@ -5,6 +5,7 @@ class PeerPeerRouter {
5
5
  this.common = new Common(router)
6
6
  }
7
7
  handle(peer) {
8
+ console.log("PeerPeerRouter", peer)
8
9
  for(let dial in peer.router) {
9
10
  let matches = peer.router[dial]
10
11
  let exposed_matches = matches.filter((m) => {
@@ -8,6 +8,7 @@ class PeerPortRouter extends Processor {
8
8
  this.connector = new Connector(router)
9
9
  }
10
10
  handle(peer) {
11
+ console.log("PeerPortRouter", peer)
11
12
  let https_domains_mapping = this.router.info()[peer.host]
12
13
  for(let dial in https_domains_mapping) {
13
14
  let parsed_dial = this.parse_ip(dial)
package/kernel/shell.js CHANGED
@@ -979,7 +979,8 @@ class Shell {
979
979
  this.queue.killAndDrain()
980
980
  if (this.ptyProcess) {
981
981
  if (cb) {
982
- kill(this.ptyProcess.pid, 'SIGKILL', () => {
982
+ let map = this.kernel.processes.map || {}
983
+ kill(this.ptyProcess.pid, map, 'SIGKILL', () => {
983
984
  console.log("child procs killed for", this.ptyProcess.pid)
984
985
  this.ptyProcess.kill()
985
986
  this.ptyProcess = undefined
@@ -989,7 +990,8 @@ class Shell {
989
990
  cb()
990
991
  });
991
992
  } else {
992
- kill(this.ptyProcess.pid, 'SIGKILL');
993
+ let map = this.kernel.processes.map || {}
994
+ kill(this.ptyProcess.pid, map, 'SIGKILL');
993
995
  console.log("child procs killed for", this.ptyProcess.pid)
994
996
  this.ptyProcess.kill()
995
997
  this.ptyProcess = undefined
@@ -5,7 +5,7 @@ var spawn = childProcess.spawn;
5
5
  var exec = childProcess.exec;
6
6
  var execSync = childProcess.execSync;
7
7
 
8
- module.exports = function (pid, signal, callback) {
8
+ module.exports = function (pid, map, signal, callback) {
9
9
  if (typeof signal === 'function' && callback === undefined) {
10
10
  callback = signal;
11
11
  signal = undefined;
@@ -31,7 +31,7 @@ module.exports = function (pid, signal, callback) {
31
31
  break;
32
32
  case 'darwin':
33
33
  buildProcessTreeMacOS(pid, tree, pidsToProcess, function () {
34
- killAll(tree, signal, callback);
34
+ killAll(tree, map, signal, callback);
35
35
  });
36
36
  break;
37
37
  // case 'sunos':
@@ -43,19 +43,20 @@ module.exports = function (pid, signal, callback) {
43
43
  buildProcessTree(pid, tree, pidsToProcess, function (parentPid) {
44
44
  return spawn('ps', ['-o', 'pid', '--no-headers', '--ppid', parentPid]);
45
45
  }, function () {
46
- killAll(tree, signal, callback);
46
+ killAll(tree, map, signal, callback);
47
47
  });
48
48
  break;
49
49
  }
50
50
  };
51
51
 
52
- function killAll (tree, signal, callback) {
52
+ function killAll (tree, map, signal, callback) {
53
+ console.log("KillAll", tree)
53
54
  var killed = {};
54
55
  try {
55
56
  Object.keys(tree).forEach(function (pid) {
56
57
  tree[pid].forEach(function (pidpid) {
57
58
  if (!killed[pidpid]) {
58
- killPid(pidpid, signal);
59
+ killPid(pidpid, map, signal);
59
60
  killed[pidpid] = 1;
60
61
  }
61
62
  });
@@ -65,7 +66,7 @@ function killAll (tree, signal, callback) {
65
66
  return
66
67
  }
67
68
  if (!killed[pid]) {
68
- killPid(pid, signal);
69
+ killPid(pid, map, signal);
69
70
  killed[pid] = 1;
70
71
  }
71
72
  });
@@ -81,8 +82,9 @@ function killAll (tree, signal, callback) {
81
82
  }
82
83
  }
83
84
 
84
- function killPid(pid, signal) {
85
+ function killPid(pid, map, signal) {
85
86
  try {
87
+ console.log("kill", pid, map[pid])
86
88
  process.kill(parseInt(pid, 10), signal);
87
89
  }
88
90
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.8.101",
3
+ "version": "3.8.102",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -3521,7 +3521,6 @@ class Server {
3521
3521
  let info = Object.assign({}, this.kernel.i)
3522
3522
  info.launch_complete = this.kernel.launch_complete
3523
3523
  console.log("kernel.launch_complete", this.kernel.launch_complete)
3524
- console.log({ info })
3525
3524
  delete info.vars
3526
3525
  delete info.shell_env
3527
3526
  delete info.memory
@@ -3946,6 +3945,7 @@ class Server {
3946
3945
  })
3947
3946
  });
3948
3947
  process.on('SIGINT', () => {
3948
+ console.log("[SigInt event]")
3949
3949
  //if (this.kernel && this.kernel.shell) {
3950
3950
  // console.log("shell reset")
3951
3951
  // this.kernel.shell.reset(() => {
@@ -3954,13 +3954,15 @@ class Server {
3954
3954
  //} else {
3955
3955
  // process.exit()
3956
3956
  //}
3957
- kill(process.pid, 'SIGKILL', () => {
3957
+ let map = this.kernel.processes.map || {}
3958
+ kill(process.pid, map, 'SIGKILL', () => {
3958
3959
  console.log("child procs killed for", process.pid)
3959
3960
  process.exit()
3960
3961
  });
3961
3962
  })
3962
3963
 
3963
3964
  process.on('SIGTERM', () => {
3965
+ console.log("[Sigterm event]")
3964
3966
  // if (this.kernel && this.kernel.shell) {
3965
3967
  // console.log("shell reset")
3966
3968
  // this.kernel.shell.reset(() => {
@@ -3969,7 +3971,16 @@ class Server {
3969
3971
  // } else {
3970
3972
  // process.exit()
3971
3973
  // }
3972
- kill(process.pid, 'SIGKILL', () => {
3974
+ let map = this.kernel.processes.map || {}
3975
+ kill(process.pid, map, 'SIGKILL', () => {
3976
+ console.log("child procs killed for", process.pid)
3977
+ process.exit()
3978
+ });
3979
+ })
3980
+ process.on('exit', () => {
3981
+ console.log("[Exit event]")
3982
+ let map = this.kernel.processes.map || {}
3983
+ kill(process.pid, map, 'SIGKILL', () => {
3973
3984
  console.log("child procs killed for", process.pid)
3974
3985
  process.exit()
3975
3986
  });