spooder 3.2.2 → 3.2.3

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.ts +29 -28
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "spooder",
3
3
  "type": "module",
4
- "version": "3.2.2",
4
+ "version": "3.2.3",
5
5
  "exports": {
6
6
  ".": {
7
7
  "bun": "./src/api.ts",
package/src/cli.ts CHANGED
@@ -36,38 +36,39 @@ async function start_server() {
36
36
  }
37
37
  }
38
38
 
39
- Bun.spawn(parse_command_line(config.run), {
39
+ const proc = Bun.spawn(parse_command_line(config.run), {
40
40
  cwd: process.cwd(),
41
41
  stdout: 'inherit',
42
- stderr: 'pipe',
43
-
44
- onExit: (proc, exitCode, signal) => {
45
- log('server exited with code %d', exitCode);
46
-
47
- if (exitCode !== null && exitCode > 0) {
48
- if (proc.stderr !== undefined) {
49
- const res = new Response(proc.stderr as ReadableStream);
50
-
51
- res.text().then(async stderr => {
52
- await dispatch_report('crash: server exited unexpectedly', [{
53
- exitCode,
54
- stderr: strip_color_codes(stderr).split(/\r?\n/)
55
- }]);
56
- });
57
- } else {
58
- dispatch_report('crash: service exited unexpectedly', [{
59
- exitCode
60
- }]);
61
- }
62
- }
42
+ stderr: 'pipe'
43
+ });
63
44
 
64
- const auto_restart_ms = config.autoRestart;
65
- if (auto_restart_ms > -1) {
66
- log('restarting server in %dms', auto_restart_ms);
67
- setTimeout(start_server, auto_restart_ms);
68
- }
45
+ await proc.exited;
46
+
47
+ const proc_exit_code = proc.exitCode;
48
+ log('server exited with code %s', proc_exit_code);
49
+
50
+ if (proc_exit_code !== 0) {
51
+ if (proc.stderr !== undefined) {
52
+ const res = new Response(proc.stderr as ReadableStream);
53
+
54
+ res.text().then(async stderr => {
55
+ await dispatch_report('crash: server exited unexpectedly', [{
56
+ proc_exit_code,
57
+ stderr: strip_color_codes(stderr).split(/\r?\n/)
58
+ }]);
59
+ });
60
+ } else {
61
+ dispatch_report('crash: service exited unexpectedly', [{
62
+ proc_exit_code
63
+ }]);
69
64
  }
70
- });
65
+ }
66
+
67
+ const auto_restart_ms = config.autoRestart;
68
+ if (auto_restart_ms > -1) {
69
+ log('restarting server in %dms', auto_restart_ms);
70
+ setTimeout(start_server, auto_restart_ms);
71
+ }
71
72
  }
72
73
 
73
74
  await start_server();