pinokiod 3.8.21 → 3.8.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.
@@ -32,9 +32,6 @@ class Caddy {
32
32
  this.kernel.exec({
33
33
  message: `caddy run --watch`,
34
34
  path: this.kernel.homedir,
35
- kill: [{
36
- message: "caddy stop"
37
- }]
38
35
  }, (e) => {
39
36
  console.log("[CADDY] " + e.cleaned)
40
37
  if (!resolved) {
@@ -57,12 +54,6 @@ class Caddy {
57
54
  {
58
55
  "match": [{ "method": ["OPTIONS"] }],
59
56
  "handle": [
60
- {
61
- "handler": "request_header",
62
- "set": {
63
- "Origin": ["http://127.0.0.1"]
64
- }
65
- },
66
57
  {
67
58
  "handler": "headers",
68
59
  "response": {
@@ -103,12 +94,6 @@ class Caddy {
103
94
  {
104
95
  "match": [{ "host": ["l.pinokio.localhost"] }],
105
96
  "handle": [
106
- {
107
- "handler": "request_header",
108
- "set": {
109
- "Origin": ["http://127.0.0.1"]
110
- }
111
- },
112
97
  {
113
98
  "handler": "reverse_proxy",
114
99
  "upstreams": [{ "dial": "127.0.0.1:1234" }]
@@ -129,12 +114,6 @@ class Caddy {
129
114
  {
130
115
  "match": [{ "host": ["o.pinokio.localhost"] }],
131
116
  "handle": [
132
- {
133
- "handler": "request_header",
134
- "set": {
135
- "Origin": ["http://127.0.0.1"]
136
- }
137
- },
138
117
  {
139
118
  "handler": "reverse_proxy",
140
119
  "upstreams": [{ "dial": "127.0.0.1:11434" }]
@@ -155,12 +134,6 @@ class Caddy {
155
134
  {
156
135
  "match": [{ "host": ["a.pinokio.localhost"] }],
157
136
  "handle": [
158
- {
159
- "handler": "request_header",
160
- "set": {
161
- "Origin": ["http://127.0.0.1"]
162
- }
163
- },
164
137
  {
165
138
  "handler": "reverse_proxy",
166
139
  "upstreams": [{ "dial": "127.0.0.1:7860" }]
@@ -181,12 +154,6 @@ class Caddy {
181
154
  {
182
155
  "match": [{ "host": ["b.pinokio.localhost"] }],
183
156
  "handle": [
184
- {
185
- "handler": "request_header",
186
- "set": {
187
- "Origin": ["http://127.0.0.1"]
188
- }
189
- },
190
157
  {
191
158
  "handler": "reverse_proxy",
192
159
  "upstreams": [{ "dial": "127.0.0.1:7861" }]
@@ -207,12 +174,6 @@ class Caddy {
207
174
  {
208
175
  "match": [{ "host": ["c.pinokio.localhost"] }],
209
176
  "handle": [
210
- {
211
- "handler": "request_header",
212
- "set": {
213
- "Origin": ["http://127.0.0.1"]
214
- }
215
- },
216
177
  {
217
178
  "handler": "reverse_proxy",
218
179
  "upstreams": [{ "dial": "127.0.0.1:7862" }]
@@ -363,9 +324,6 @@ class Caddy {
363
324
  this.kernel.exec({
364
325
  message: `caddy run --watch`,
365
326
  path: this.kernel.homedir,
366
- kill: [{
367
- message: "caddy stop"
368
- }]
369
327
  }, (e) => {
370
328
  resolve()
371
329
  console.log("[CADDY] " + e.cleaned)
@@ -384,10 +342,6 @@ class Caddy {
384
342
  path: this.kernel.homedir
385
343
  }, (e) => {
386
344
  ondata(e)
387
- // console.log(e)
388
- // if (/Caddy Local Authority/i.test(e.cleaned)) {
389
- // trusted = true
390
- // }
391
345
  })
392
346
  } else {
393
347
  console.log("req", req)
package/kernel/shell.js CHANGED
@@ -2,7 +2,7 @@ const { Terminal } = require('xterm-headless');
2
2
  const { SerializeAddon } = require("xterm-addon-serialize");
3
3
  const sanitize = require("sanitize-filename");
4
4
  const YAML = require('yaml')
5
-
5
+ const kill = require('tree-kill');
6
6
  const fastq = require('fastq')
7
7
  const { v4: uuidv4 } = require('uuid');
8
8
  const os = require('os');
@@ -60,8 +60,6 @@ class Shell {
60
60
 
61
61
  }
62
62
  async init_env(params) {
63
- console.log({ params })
64
- console.time("> 1")
65
63
  this.env = Object.assign({}, process.env)
66
64
  // If the user has set PYTHONPATH, unset it.
67
65
  if (this.env.PYTHONPATH) {
@@ -90,16 +88,12 @@ class Shell {
90
88
  // }
91
89
  for(let key in this.env) {
92
90
  if (key.startsWith("CUDA")) {
93
- console.log("Unset env key: " + key)
94
91
  delete this.env[key]
95
92
  }
96
93
  if (/.*(SSH|SSL).*/.test(key)) {
97
- console.log("Unset env key: " + key)
98
94
  delete this.env[key]
99
95
  }
100
96
  }
101
- console.timeEnd("> 1")
102
- console.time("> 2")
103
97
 
104
98
  this.env.CMAKE_OBJECT_PATH_MAX = 1024
105
99
  this.env.PYTORCH_ENABLE_MPS_FALLBACK = 1
@@ -113,9 +107,7 @@ class Shell {
113
107
  // First override this.env with system env
114
108
  let system_env = await Environment.get(this.kernel.homedir)
115
109
  this.env = Object.assign(this.env, system_env)
116
- console.timeEnd("> 2")
117
110
 
118
- console.time("> 3")
119
111
  // if the shell is running from a script file, the params.$parent will include the path to the parent script
120
112
  // this means we need to apply app environment as well
121
113
  if (params.$parent) {
@@ -147,7 +139,6 @@ class Shell {
147
139
 
148
140
  if (this.platform === "linux") {
149
141
  let gxx = this.kernel.which('g++')
150
- console.log({ gxx })
151
142
  if (gxx) {
152
143
  this.env.NVCC_PREPEND_FLAGS = `-ccbin ${gxx}`
153
144
  }
@@ -156,8 +147,6 @@ class Shell {
156
147
  this.env[PATH_KEY] = this.env[PATH_KEY] + path.delimiter + path.resolve(this.kernel.homedir, 'bin')
157
148
 
158
149
 
159
- console.timeEnd("> 3")
160
- console.time("> 4")
161
150
  if (params.env) {
162
151
  for(let key in params.env) {
163
152
  // iterate through the env attributes
@@ -191,10 +180,6 @@ class Shell {
191
180
  }
192
181
  }
193
182
  }
194
- console.timeEnd("> 4")
195
-
196
-
197
- console.time("> 5")
198
183
  for(let key in this.env) {
199
184
  if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(key) && key !== "ProgramFiles(x86)") {
200
185
  delete this.env[key]
@@ -213,7 +198,6 @@ class Shell {
213
198
  delete this.env[key]
214
199
  }
215
200
  }
216
- console.timeEnd("> 5")
217
201
  }
218
202
  async start(params, ondata) {
219
203
  this.ondata = ondata
@@ -245,9 +229,6 @@ class Shell {
245
229
  this.rows = params.client.rows
246
230
  }
247
231
 
248
- console.log({ cols: this.cols, rows: this.rows })
249
-
250
-
251
232
  this.vt = new Terminal({
252
233
  allowProposedApi: true,
253
234
  cols: this.cols,
@@ -280,13 +261,13 @@ class Shell {
280
261
  if (params.sudo) {
281
262
  let options = {
282
263
  name: "Pinokio",
283
- env: {}
264
+ // env: {}
284
265
  // icns: '/Applications/Electron.app/Contents/Resources/Electron.icns', // (optional)
285
266
  };
286
267
 
287
- for(let key in this.env) {
288
- options.env[key] = String(this.env[key])
289
- }
268
+ // for(let key in this.env) {
269
+ // options.env[key] = String(this.env[key])
270
+ // }
290
271
 
291
272
  // sudo-prompt uses TEMP
292
273
  await fs.promises.mkdir(this.env.TEMP, { recursive: true }).catch((e) => { })
@@ -297,7 +278,6 @@ class Shell {
297
278
  // Modify process.env (and need to immediately revert it back to original process.env so as to not affect other logic)
298
279
  let old_env = process.env
299
280
  process.env = this.env
300
- console.log("sudo process.env", process.env)
301
281
  sudo.exec(params.message, options, (err, stdout, stderr) => {
302
282
  if (err) {
303
283
  console.log("SUDOPROMPT ERR", err)
@@ -343,7 +323,6 @@ class Shell {
343
323
  return;
344
324
  }
345
325
  let chunk = message.slice(i, i+1024)
346
- console.log("Writing chunk", chunk)
347
326
  this.ptyProcess.write(chunk)
348
327
  i += 1024;
349
328
  }, 10);
@@ -972,14 +951,7 @@ class Shell {
972
951
  this.ondata({ raw: `\r\n\r\n██ Detached from Shell ${this.id}\r\n\r\n` })
973
952
  }
974
953
  }
975
- runSequentially(tasks) {
976
- let chain = Promise.resolve();
977
- for (const task of tasks) {
978
- chain = chain.then(() => task());
979
- }
980
- return chain;
981
- }
982
- kill(message, force) {
954
+ kill(message, force, cb) {
983
955
  console.log("KILL")
984
956
 
985
957
  this.done = true
@@ -1004,36 +976,24 @@ class Shell {
1004
976
  this.vt.dispose()
1005
977
  this.queue.killAndDrain()
1006
978
  if (this.ptyProcess) {
1007
- if (this.kill_messages) {
1008
- console.log({ kill_messages: this.kill_messages })
1009
- let promises = this.kill_messages.map((m) => {
1010
- return new Promise(async (resolve, reject) => {
1011
- await this.kernel.exec(m, this.ondata)
1012
- resolve()
1013
- })
1014
- })
1015
- this.runSequentially(promises).then(() => {
1016
- console.log("Running kill message", { kill_messages })
1017
- this.ptyProcess.write(kill_messages)
979
+ if (cb) {
980
+ console.log("tree kill", this.ptyProcess.pid)
981
+ kill(this.ptyProcess.pid, 'SIGKILL', () => {
1018
982
  this.ptyProcess.kill()
1019
983
  this.ptyProcess = undefined
1020
- // automatically remove the shell from this.kernel.shells
1021
- this.kernel.shell.rm(this.id)
1022
- this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
1023
- })
984
+ cb()
985
+ });
1024
986
  } else {
987
+ console.log("tree kill", this.ptyProcess.pid)
988
+ kill(this.ptyProcess.pid, 'SIGKILL');
1025
989
  this.ptyProcess.kill()
1026
990
  this.ptyProcess = undefined
1027
- // automatically remove the shell from this.kernel.shells
1028
- this.kernel.shell.rm(this.id)
1029
- this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
1030
991
  }
1031
- } else {
1032
- // automatically remove the shell from this.kernel.shells
1033
- this.kernel.shell.rm(this.id)
1034
- this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
1035
992
  }
1036
993
 
994
+ // automatically remove the shell from this.kernel.shells
995
+ this.kernel.shell.rm(this.id)
996
+ this.ondata({ raw: `\r\n\r\n██ Terminated Shell ${this.id}\r\n████\r\n` })
1037
997
 
1038
998
  }
1039
999
  log() {
package/kernel/shells.js CHANGED
@@ -358,7 +358,7 @@ class Shells {
358
358
  stop (request, message) {
359
359
  return this.kill(request, message)
360
360
  }
361
- reset() {
361
+ reset(cb) {
362
362
  let info = this.shells.map((s) => {
363
363
  return { id: s.id, group: s.group, cmd: s.cmd }
364
364
  })
@@ -367,9 +367,19 @@ class Shells {
367
367
  for(let i=0; i<this.shells.length; i++) {
368
368
  shells.push(this.shells[i])
369
369
  }
370
+ let count = 0
370
371
  for(let shell of shells) {
371
372
  console.log("[Kill Shell]", { id: shell.id, group: shell.group, cmd: shell.cmd })
372
- shell.kill("", true)
373
+ if (cb) {
374
+ shell.kill("", true, () => {
375
+ count++
376
+ if (count >= shells.length) {
377
+ cb()
378
+ }
379
+ })
380
+ } else {
381
+ shell.kill("", true)
382
+ }
373
383
  }
374
384
  }
375
385
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.8.21",
3
+ "version": "3.8.23",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -60,6 +60,7 @@
60
60
  "sudo-prompt-programfiles-x86": "^9.2.10",
61
61
  "symlink-dir": "^5.2.1",
62
62
  "systeminformation": "^5.18.4",
63
+ "tree-kill": "^1.2.2",
63
64
  "uuid": "^9.0.0",
64
65
  "wait-on": "^7.2.0",
65
66
  "which": "^5.0.0",
package/server/index.js CHANGED
@@ -3846,13 +3846,19 @@ class Server {
3846
3846
  });
3847
3847
  process.on('SIGINT', () => {
3848
3848
  console.log("SIGINT Event")
3849
- if (this.kernel && this.kernel.shell) this.kernel.shell.reset()
3850
- process.exit()
3849
+ if (this.kernel && this.kernel.shell) {
3850
+ this.kernel.shell.reset(() => {
3851
+ process.exit()
3852
+ })
3853
+ }
3851
3854
  })
3852
3855
  process.on('SIGTERM', () => {
3853
3856
  console.log("SIGTERM Event")
3854
- if (this.kernel && this.kernel.shell) this.kernel.shell.reset()
3855
- process.exit()
3857
+ if (this.kernel && this.kernel.shell) {
3858
+ this.kernel.shell.reset(() => {
3859
+ process.exit()
3860
+ })
3861
+ }
3856
3862
  })
3857
3863
  // process.on('exit', () => {
3858
3864
  // console.log("exit Event")