pinokiod 3.84.0 → 3.86.0

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.
Files changed (55) hide show
  1. package/kernel/api/index.js +7 -0
  2. package/kernel/bin/caddy.js +10 -4
  3. package/kernel/peer.js +14 -11
  4. package/kernel/prototype.js +1 -0
  5. package/kernel/shell.js +43 -2
  6. package/kernel/util.js +2 -0
  7. package/package.json +1 -1
  8. package/pipe/views/login.ejs +1 -1
  9. package/server/index.js +139 -86
  10. package/server/public/common.js +534 -0
  11. package/server/public/opener.js +12 -11
  12. package/server/public/serve/style.css +1 -1
  13. package/server/public/style.css +25 -24
  14. package/server/public/urldropdown.css +474 -5
  15. package/server/public/urldropdown.js +233 -12
  16. package/server/views/404.ejs +1 -1
  17. package/server/views/500.ejs +1 -1
  18. package/server/views/app.ejs +29 -33
  19. package/server/views/bookmarklet.ejs +197 -0
  20. package/server/views/connect/x.ejs +4 -4
  21. package/server/views/connect.ejs +10 -10
  22. package/server/views/container.ejs +2 -2
  23. package/server/views/d.ejs +3 -3
  24. package/server/views/download.ejs +1 -1
  25. package/server/views/editor.ejs +1 -1
  26. package/server/views/env_editor.ejs +3 -3
  27. package/server/views/explore.ejs +2 -2
  28. package/server/views/file_explorer.ejs +2 -2
  29. package/server/views/git.ejs +7 -7
  30. package/server/views/github.ejs +3 -3
  31. package/server/views/help.ejs +2 -2
  32. package/server/views/index.ejs +5 -5
  33. package/server/views/index2.ejs +3 -3
  34. package/server/views/init/index.ejs +11 -74
  35. package/server/views/install.ejs +3 -3
  36. package/server/views/keys.ejs +2 -2
  37. package/server/views/mini.ejs +2 -2
  38. package/server/views/net.ejs +6 -6
  39. package/server/views/network.ejs +22 -22
  40. package/server/views/network2.ejs +10 -10
  41. package/server/views/old_network.ejs +8 -8
  42. package/server/views/pro.ejs +369 -0
  43. package/server/views/prototype/index.ejs +2 -2
  44. package/server/views/required_env_editor.ejs +2 -2
  45. package/server/views/review.ejs +6 -6
  46. package/server/views/screenshots.ejs +5 -4
  47. package/server/views/settings.ejs +3 -3
  48. package/server/views/setup.ejs +2 -2
  49. package/server/views/setup_home.ejs +2 -2
  50. package/server/views/share_editor.ejs +4 -4
  51. package/server/views/shell.ejs +3 -3
  52. package/server/views/start.ejs +2 -2
  53. package/server/views/task.ejs +2 -2
  54. package/server/views/terminal.ejs +5 -4
  55. package/server/views/tools.ejs +13 -13
package/server/index.js CHANGED
@@ -108,10 +108,53 @@ class Server {
108
108
  stop() {
109
109
  this.server.close()
110
110
  }
111
+ killProcessTree(pid, label) {
112
+ const numericPid = typeof pid === 'string' ? parseInt(pid, 10) : pid
113
+ if (!Number.isInteger(numericPid) || numericPid <= 0) {
114
+ return
115
+ }
116
+ if (label) {
117
+ console.log(label, numericPid)
118
+ }
119
+ try {
120
+ kill(numericPid, 'SIGKILL', true)
121
+ } catch (error) {
122
+ if (error && error.code === 'ESRCH') {
123
+ return
124
+ }
125
+ console.error(`Failed to kill pid ${numericPid}`, error)
126
+ }
127
+ }
128
+ killTrackedProcesses() {
129
+ if (this.kernel && this.kernel.processes && this.kernel.processes.map) {
130
+ for (const [pid, name] of Object.entries(this.kernel.processes.map)) {
131
+ if (parseInt(pid, 10) === process.pid) {
132
+ continue
133
+ }
134
+ this.killProcessTree(pid, `kill child ${name}`)
135
+ }
136
+ }
137
+ }
138
+ shutdown(signalLabel) {
139
+ const label = signalLabel || 'Shutdown'
140
+ console.log(`[${label} event] Kill`, process.pid)
141
+ if (this.kernel && this.kernel.shell) {
142
+ try {
143
+ this.kernel.shell.reset()
144
+ } catch (error) {
145
+ console.error('Failed to reset shells', error)
146
+ }
147
+ }
148
+ this.killTrackedProcesses()
149
+ if (this.kernel && this.kernel.processes && this.kernel.processes.caddy_pid) {
150
+ this.killProcessTree(this.kernel.processes.caddy_pid, 'kill caddy')
151
+ }
152
+ this.killProcessTree(process.pid, 'kill self')
153
+ }
111
154
  exists (s) {
112
155
  return new Promise(r=>fs.access(s, fs.constants.F_OK, e => r(!e)))
113
156
  }
114
- running_dynamic (name, menu) {
157
+ running_dynamic (name, menu, selected_query) {
115
158
  let cwd = this.kernel.path("api", name)
116
159
  let running_dynamic = []
117
160
  const traverse = (obj, indexPath) => {
@@ -136,9 +179,17 @@ class Server {
136
179
 
137
180
  let id = `${filepath}?cwd=${cwd}`
138
181
  //if (this.kernel.api.running[filepath]) {
139
- if (this.kernel.api.running[id]) {
182
+ if (this.kernel.api.running[id] || selected_query.plugin === obj.src) {
140
183
  obj.running = true
141
184
  obj.display = "indent"
185
+ if (selected_query.plugin === obj.src) {
186
+ obj.default = true
187
+ for(let key in selected_query) {
188
+ if (key !== "plugin") {
189
+ obj.href = obj.href + "&" + key + "=" + encodeURIComponent(selected_query[key])
190
+ }
191
+ }
192
+ }
142
193
  running_dynamic.push(obj)
143
194
  }
144
195
  } else if (href.startsWith("/run")) {
@@ -148,9 +199,18 @@ class Server {
148
199
  let id = `${filepath}?cwd=${cwd}`
149
200
  obj.script_id = id
150
201
  //if (this.kernel.api.running[filepath]) {
151
- if (this.kernel.api.running[id]) {
202
+ if (this.kernel.api.running[id] || selected_query.plugin === obj.src) {
152
203
  obj.running = true
153
204
  obj.display = "indent"
205
+ if (selected_query.plugin === obj.src) {
206
+ console.log("selected_query", selected_query)
207
+ obj.default = true
208
+ for(let key in selected_query) {
209
+ if (key !== "plugin") {
210
+ obj.href = obj.href + "&" + key + "=" + encodeURIComponent(selected_query[key])
211
+ }
212
+ }
213
+ }
154
214
  running_dynamic.push(obj)
155
215
  }
156
216
  }
@@ -158,9 +218,19 @@ class Server {
158
218
  let unix_path = Util.p2u(this.kernel.path("api", name))
159
219
  let shell_id = this.get_shell_id(unix_path, indexPath, obj[key])
160
220
  let decoded_shell_id = decodeURIComponent(shell_id)
161
- if (this.kernel.api.running["shell/" + decoded_shell_id]) {
221
+ let id = "shell/" + decoded_shell_id
222
+ if (this.kernel.api.running[id] || selected_query.plugin === id) {
162
223
  obj.running = true
163
224
  obj.display = "indent"
225
+ if (selected_query.plugin === id) {
226
+ obj.default = true
227
+ console.log("selected_query", selected_query)
228
+ for(let key in selected_query) {
229
+ if (key !== "plugin") {
230
+ obj.href = obj.href + "&" + key + "=" + encodeURIComponent(selected_query[key])
231
+ }
232
+ }
233
+ }
164
234
  running_dynamic.push(obj)
165
235
  }
166
236
  }
@@ -292,20 +362,20 @@ class Server {
292
362
  }
293
363
  }
294
364
  } else {
295
- cfg = await this.renderIndex(name)
365
+ cfg = await this.renderIndex(name, cfg)
296
366
  }
297
367
  } else {
298
- cfg = await this.renderIndex(name)
368
+ cfg = await this.renderIndex(name, cfg)
299
369
  }
300
370
  return cfg
301
371
  }
302
- async renderIndex(name) {
372
+ async renderIndex(name, cfg) {
303
373
  let p = this.kernel.path("api", name)
304
374
  let html_path = path.resolve(p, "index.html")
305
375
  let html_exists = await this.kernel.exists(html_path)
306
376
  console.log({ html_path, html_exists })
307
377
  if (html_exists) {
308
- return {
378
+ return Object.assign({
309
379
  title: name,
310
380
  menu: [{
311
381
  default: true,
@@ -313,9 +383,9 @@ class Server {
313
383
  text: "index.html",
314
384
  href: "index.html?raw=true",
315
385
  }]
316
- }
386
+ }, cfg)
317
387
  } else {
318
- return {
388
+ return Object.assign({
319
389
  title: name,
320
390
  menu: [{
321
391
  default: true,
@@ -323,7 +393,7 @@ class Server {
323
393
  text: "Project Files",
324
394
  href: `/files/api/${name}`,
325
395
  }]
326
- }
396
+ }, cfg)
327
397
  }
328
398
  }
329
399
  async getGit(ref, filepath) {
@@ -520,9 +590,7 @@ class Server {
520
590
  err = e.stack
521
591
  }
522
592
 
523
- console.log("renderMenu before", config)
524
593
  await this.renderMenu(req, uri, name, config, [])
525
- console.log("renderMenu after", config)
526
594
 
527
595
  let platform = os.platform()
528
596
 
@@ -602,7 +670,11 @@ class Server {
602
670
  let plugin = await this.getPlugin(req, plugin_config, name)
603
671
  if (plugin && plugin.menu && Array.isArray(plugin.menu)) {
604
672
  plugin = structuredClone(plugin)
605
- plugin_menu = this.running_dynamic(name, plugin.menu)
673
+ let default_plugin_query
674
+ if (req.query) {
675
+ default_plugin_query = req.query
676
+ }
677
+ plugin_menu = this.running_dynamic(name, plugin.menu, default_plugin_query)
606
678
  }
607
679
 
608
680
  let posix_path = Util.p2u(this.kernel.path("api", name))
@@ -617,6 +689,18 @@ class Server {
617
689
  let dev_tab = "/p/" + name + "/dev"
618
690
  let review_tab = "/p/" + name + "/review"
619
691
 
692
+ let dynamic_url = "/pinokio/dynamic/" + name;
693
+ if (Object.values(req.query).length > 0) {
694
+ let index = 0
695
+ for(let key in req.query) {
696
+ if (index === 0) {
697
+ dynamic_url = dynamic_url + `?${key}=${encodeURIComponent(req.query[key])}`
698
+ } else {
699
+ dynamic_url = dynamic_url + `&${key}=${encodeURIComponent(req.query[key])}`
700
+ }
701
+ index++;
702
+ }
703
+ }
620
704
 
621
705
  const result = {
622
706
  dev_link,
@@ -639,7 +723,7 @@ class Server {
639
723
  sidebar: "/pinokio/sidebar/" + name,
640
724
  repos: "/pinokio/repos/" + name,
641
725
  ai: "/pinokio/ai/" + name,
642
- dynamic: "/pinokio/dynamic/" + name,
726
+ dynamic: dynamic_url,
643
727
  // dynamic: "/pinokio/dynamic/" + name,
644
728
  dynamic_content: null,
645
729
  name,
@@ -1019,7 +1103,6 @@ class Server {
1019
1103
  template = "editor"
1020
1104
  }
1021
1105
 
1022
- console.log("check requirements")
1023
1106
  let { requirements, install_required, requirements_pending, error } = await this.kernel.bin.check({
1024
1107
  //bin: this.kernel.bin.preset("ai"),
1025
1108
  bin: this.kernel.bin.preset("dev"),
@@ -1076,7 +1159,6 @@ class Server {
1076
1159
  if (platform === "win32") {
1077
1160
  root_path = root_path.replace(/\\/g, '\\\\')
1078
1161
  }
1079
- console.log({ cwd, api_path, root, root_path })
1080
1162
  res.render("required_env_editor", {
1081
1163
  portal: this.portal,
1082
1164
  agent: req.agent,
@@ -1613,7 +1695,6 @@ class Server {
1613
1695
  items
1614
1696
  })
1615
1697
  } else {
1616
- console.log("RENDER FILE EXPLORER")
1617
1698
  res.render("file_explorer", {
1618
1699
  docs: this.docs,
1619
1700
  portal: this.portal,
@@ -2033,7 +2114,6 @@ class Server {
2033
2114
  if (menuitem.image.startsWith("/")) {
2034
2115
  imagePath = menuitem.image
2035
2116
  } else {
2036
- console.log({ launcher_root, name, image: menuitem.image })
2037
2117
  if (launcher_root) {
2038
2118
  imagePath = `/api/${name}/${launcher_root}/${menuitem.image}?raw=true`
2039
2119
  } else {
@@ -2664,11 +2744,13 @@ class Server {
2664
2744
  }
2665
2745
  getPeers() {
2666
2746
  let list = []
2667
- for(let key in this.kernel.peer.info) {
2668
- // if (key !== this.kernel.peer.host) {
2747
+ if (this.kernel.peer.active) {
2748
+ for(let key in this.kernel.peer.info) {
2669
2749
  let info = this.kernel.peer.info[key]
2670
- list.push(info)
2671
- // }
2750
+ if (info.active) {
2751
+ list.push(info)
2752
+ }
2753
+ }
2672
2754
  }
2673
2755
  return list
2674
2756
  }
@@ -3073,7 +3155,6 @@ class Server {
3073
3155
  ...result
3074
3156
  })
3075
3157
  }
3076
- console.log(JSON.stringify(bundles, null, 2))
3077
3158
  res.render("tools", {
3078
3159
  current_host: this.kernel.peer.host,
3079
3160
  pending,
@@ -3123,6 +3204,23 @@ class Server {
3123
3204
  })
3124
3205
  }))
3125
3206
 
3207
+ this.app.get("/bookmarklet", ex(async (req, res) => {
3208
+ const protocol = (req.$source && req.$source.protocol) || req.protocol || 'http';
3209
+ const host = req.get('host') || `localhost:${this.port}`;
3210
+ const baseUrl = `${protocol}://${host}`;
3211
+ const targetBase = `${baseUrl}/?create=1&prompt=`;
3212
+ const safeTargetBase = targetBase.replace(/'/g, "\\'");
3213
+ const bookmarkletHref = `javascript:(()=>{window.open('${safeTargetBase}'+encodeURIComponent(window.location.href),'_blank');})();`;
3214
+
3215
+ res.render("bookmarklet", {
3216
+ theme: this.theme,
3217
+ agent: req.agent,
3218
+ baseUrl,
3219
+ targetBase,
3220
+ bookmarkletHref
3221
+ });
3222
+ }))
3223
+
3126
3224
  //let home = this.kernel.homedir
3127
3225
  //let home = this.kernel.store.get("home")
3128
3226
  this.app.get("/launch", ex(async (req, res) => {
@@ -3143,7 +3241,6 @@ class Server {
3143
3241
  autolaunch = true
3144
3242
  }
3145
3243
  let chunks = host.split(".")
3146
- console.log("GET /launch", { url, host, chunks })
3147
3244
  if (chunks[chunks.length-1] === "localhost") {
3148
3245
  // if <...>.<kernel.peer.name>.localhost
3149
3246
  let nameChunks
@@ -3170,7 +3267,6 @@ class Server {
3170
3267
  for(let folder of folders) {
3171
3268
  let pattern1 = `${folder}.${this.kernel.peer.name}.localhost`
3172
3269
  let pattern2 = `${folder}.localhost`
3173
- console.log("checking", { pattern1, pattern2, chunks: chunks.join(".") })
3174
3270
  if (pattern1 === chunks.join(".")) {
3175
3271
  matched = true
3176
3272
  nameChunks = chunks.slice(0, -2)
@@ -3191,20 +3287,16 @@ class Server {
3191
3287
  // look for any matching peer names
3192
3288
  // if exists, redirect to that host
3193
3289
  for(let name of peer_names) {
3194
- console.log({ host, name })
3195
3290
  if (host.endsWith(`.${name}.localhost`)) {
3196
- console.log("matched. redirecting")
3197
3291
  res.redirect(`https://pinokio.${name}.localhost/launch?url=${url}`)
3198
3292
  return
3199
3293
  }
3200
3294
  }
3201
3295
  }
3202
3296
  } else {
3203
- console.log("> 3")
3204
3297
  nameChunks = chunks
3205
3298
  }
3206
3299
  let name = nameChunks.join(".")
3207
- console.log({ nameChunks, chunks, name })
3208
3300
  let api_path = this.kernel.path("api", name)
3209
3301
  let exists = await this.exists(api_path)
3210
3302
  if (exists) {
@@ -3554,7 +3646,6 @@ class Server {
3554
3646
  } catch (e) {
3555
3647
  console.log(e)
3556
3648
  }
3557
- console.log({ https_running })
3558
3649
  if (!https_running) {
3559
3650
  // res.json({ error: "pinokio.host not yet available" })
3560
3651
  res.redirect("/setup/connect?callback=/connect/" + req.params.provider)
@@ -3572,7 +3663,6 @@ class Server {
3572
3663
  break
3573
3664
  }
3574
3665
  }
3575
- console.log({ router_running })
3576
3666
  if (!router_running) {
3577
3667
  // res.json({ error: "pinokio.localhost not yet available" })
3578
3668
  res.redirect("/setup/connect?callback=/connect/" + req.params.provider)
@@ -3675,7 +3765,6 @@ class Server {
3675
3765
  res.json({ success: true })
3676
3766
  }))
3677
3767
  this.app.post("/go", ex(async (req, res) => {
3678
- console.log("GO", req.body)
3679
3768
  Util.openURL(req.body.url)
3680
3769
  res.json({ success: true })
3681
3770
  }))
@@ -3689,7 +3778,6 @@ class Server {
3689
3778
  // relpath : ...
3690
3779
  let relpath = req.body.asset_path.split("/").filter((x) => { return x }).slice(1).join("/")
3691
3780
  let filepath = this.kernel.path(relpath)
3692
- console.log({ filepath, relpath })
3693
3781
  Util.openfs(filepath, req.body, this.kernel)
3694
3782
  } else if (req.body.path) {
3695
3783
  Util.openfs(req.body.path, req.body, this.kernel)
@@ -3699,7 +3787,6 @@ class Server {
3699
3787
  this.app.post("/keys", ex(async (req, res) => {
3700
3788
  let p = this.kernel.path("key.json")
3701
3789
  let keys = (await this.kernel.loader.load(p)).resolved
3702
- console.log("update", req.body)
3703
3790
  for(let host in req.body) {
3704
3791
  let updated = req.body[host]
3705
3792
  for(let indexStr in updated) {
@@ -3804,8 +3891,6 @@ class Server {
3804
3891
 
3805
3892
  let hosts = await this.get_github_hosts()
3806
3893
 
3807
- console.log("hosts", hosts)
3808
-
3809
3894
  let items
3810
3895
  if (hosts.length > 0) {
3811
3896
  // logged in => display logout
@@ -4016,6 +4101,16 @@ class Server {
4016
4101
  running: (shell ? true : false)
4017
4102
  })
4018
4103
  }))
4104
+ this.app.get("/pro", ex(async (req, res) => {
4105
+ let target = req.query.target ? req.query.target : null
4106
+ let cwd = this.kernel.path("api")
4107
+ res.render("pro", {
4108
+ target,
4109
+ cwd,
4110
+ theme: this.theme,
4111
+ agent: req.agent,
4112
+ })
4113
+ }))
4019
4114
  // this.app.get("/terminal/:api/:id", ex(async (req, res) => {
4020
4115
  // res.render("shell", {
4021
4116
  // theme: this.theme,
@@ -4087,7 +4182,6 @@ class Server {
4087
4182
  if (cr.has("caddy")) {
4088
4183
  wait = "caddy"
4089
4184
  }
4090
- console.log({ wait, cr })
4091
4185
 
4092
4186
  let current = req.query.callback || req.originalUrl
4093
4187
 
@@ -4241,7 +4335,6 @@ class Server {
4241
4335
  return
4242
4336
  }
4243
4337
 
4244
-
4245
4338
  // let list = this.getPeerInfo()
4246
4339
  // console.log("peeerInfo", JSON.stringify(list, null, 2))
4247
4340
  await this.kernel.peer.check_peers()
@@ -4825,7 +4918,6 @@ class Server {
4825
4918
  //const repositoryPath = this.kernel.path(pathComponents[0], pathComponents[1])
4826
4919
  //const repositoryPath = this.kernel.path(pathComponents[0])
4827
4920
  const repositoryPath = path.resolve(this.kernel.api.userdir, api_path)
4828
- console.log({ repositoryPath })
4829
4921
  gitRemote = await git.getConfig({
4830
4922
  fs,
4831
4923
  http,
@@ -4971,7 +5063,6 @@ class Server {
4971
5063
  if (config) {
4972
5064
  if (config.xterm) {
4973
5065
  this.xterm = config.xterm
4974
- console.log("this.xterm", this.xterm)
4975
5066
  }
4976
5067
  }
4977
5068
  }
@@ -5306,7 +5397,6 @@ class Server {
5306
5397
  })
5307
5398
  }))
5308
5399
  this.app.get("/dev/*", ex(async (req, res) => {
5309
- console.log("GET /dev/*", req.params)
5310
5400
  let { requirements, install_required, requirements_pending, error } = await this.kernel.bin.check({
5311
5401
  bin: this.kernel.bin.preset("dev"),
5312
5402
  })
@@ -5441,7 +5531,11 @@ class Server {
5441
5531
  if (plugin) {
5442
5532
  if (plugin && plugin.menu && Array.isArray(plugin.menu)) {
5443
5533
  plugin = structuredClone(plugin)
5444
- plugin_menu = this.running_dynamic(req.params.name, plugin.menu)
5534
+ let default_plugin_query
5535
+ if (req.query) {
5536
+ default_plugin_query = req.query
5537
+ }
5538
+ plugin_menu = this.running_dynamic(req.params.name, plugin.menu, default_plugin_query)
5445
5539
  html = await new Promise((resolve, reject) => {
5446
5540
  ejs.renderFile(path.resolve(__dirname, "views/partials/dynamic.ejs"), { dynamic: plugin_menu }, (err, html) => {
5447
5541
  resolve(html)
@@ -5749,7 +5843,6 @@ class Server {
5749
5843
  let gitRemote = null
5750
5844
  try {
5751
5845
  const repositoryPath = path.resolve(this.kernel.api.userdir, req.params.name)
5752
- console.log({ repositoryPath })
5753
5846
  gitRemote = await git.getConfig({
5754
5847
  fs,
5755
5848
  http,
@@ -5902,7 +5995,6 @@ class Server {
5902
5995
  res.redirect("/pinokio/install")
5903
5996
  }))
5904
5997
  this.app.get("/pinokio/install", ex((req, res) => {
5905
- console.log("render /pinokio/install")
5906
5998
  let requirements = req.session.requirements
5907
5999
  let callback = req.session.callback
5908
6000
  req.session.requirements = null
@@ -6084,7 +6176,6 @@ class Server {
6084
6176
  await fs.promises.mkdir(this.kernel.path("screenshots"), { recursive: true }).catch((e) => { })
6085
6177
  for(let key in req.files) {
6086
6178
  let file = req.files[key]
6087
- console.log({ file, key })
6088
6179
  let ts = String(Date.now()) + ".png"
6089
6180
  await fs.promises.writeFile(this.kernel.path("screenshots", ts), file.buffer)
6090
6181
  }
@@ -6275,7 +6366,6 @@ class Server {
6275
6366
  }
6276
6367
  } else {
6277
6368
  // if network is not active, return success immediately (just checking if the server is up)
6278
- console.log("this.kernel.router.published()")
6279
6369
  res.json({ success: true })
6280
6370
  }
6281
6371
  }))
@@ -6337,48 +6427,11 @@ class Server {
6337
6427
  })
6338
6428
  });
6339
6429
  process.on('SIGINT', () => {
6340
- //if (this.kernel && this.kernel.shell) {
6341
- // console.log("shell reset")
6342
- // this.kernel.shell.reset(() => {
6343
- // process.exit()
6344
- // })
6345
- //} else {
6346
- // process.exit()
6347
- //}
6348
- console.log("[SigInt event] Kill", process.pid)
6349
- if (this.kernel.processes.caddy_pid) {
6350
- console.log("kill caddy", this.kernel.processes.caddy_pid)
6351
- kill(this.kernel.processes.caddy_pid, "SIGKILL", true)
6352
- }
6353
- console.log("kill self")
6354
- kill(process.pid, 'SIGKILL', true)
6355
- //kill(process.pid, map, 'SIGKILL', () => {
6356
- // console.log("child procs killed for", process.pid)
6357
- // process.exit()
6358
- //});
6430
+ this.shutdown('SigInt')
6359
6431
  })
6360
6432
 
6361
6433
  process.on('SIGTERM', () => {
6362
- // if (this.kernel && this.kernel.shell) {
6363
- // console.log("shell reset")
6364
- // this.kernel.shell.reset(() => {
6365
- // process.exit()
6366
- // })
6367
- // } else {
6368
- // process.exit()
6369
- // }
6370
- console.log("[Sigterm event] Kill", process.pid)
6371
- if (this.kernel.processes.caddy_pid) {
6372
- console.log("kill caddy", this.kernel.processes.caddy_pid)
6373
- kill(this.kernel.processes.caddy_pid, "SIGKILL", true)
6374
- }
6375
- console.log("kill self")
6376
- kill(process.pid, 'SIGKILL', true)
6377
- //let map = this.kernel.processes.map || {}
6378
- //kill(process.pid, map, 'SIGKILL', () => {
6379
- // console.log("child procs killed for", process.pid)
6380
- // process.exit()
6381
- //});
6434
+ this.shutdown('SigTerm')
6382
6435
  })
6383
6436
  // process.on('exit', () => {
6384
6437
  // console.log("[Exit event]")