@astroscope/boot 0.2.1 → 0.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.
- package/dist/index.cjs +18 -2
- package/dist/index.js +18 -2
- package/dist/warmup.cjs +4 -1
- package/dist/warmup.js +4 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -230,8 +230,24 @@ function boot(options = {}) {
|
|
|
230
230
|
const bootImport = `globalThis.__astroscope_server_url = import.meta.url;
|
|
231
231
|
import * as __boot from './${bootChunkName}';
|
|
232
232
|
const __bootContext = { dev: false, host: process.env.HOST ?? '${host}', port: process.env.PORT ? Number(process.env.PORT) : ${port} };
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
try {
|
|
234
|
+
await __boot.onStartup?.(__bootContext);
|
|
235
|
+
} catch (err) {
|
|
236
|
+
console.error('[boot] startup failed:', err);
|
|
237
|
+
try { await __boot.onShutdown?.(__bootContext); } catch {}
|
|
238
|
+
process.exit(1);
|
|
239
|
+
}
|
|
240
|
+
if (__boot.onShutdown) {
|
|
241
|
+
process.on('SIGTERM', async () => {
|
|
242
|
+
try {
|
|
243
|
+
await __boot.onShutdown(__bootContext);
|
|
244
|
+
process.exit(0);
|
|
245
|
+
} catch (err) {
|
|
246
|
+
console.error('[boot] shutdown failed:', err);
|
|
247
|
+
process.exit(1);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
235
251
|
`;
|
|
236
252
|
const s = new import_magic_string.default(entryChunk.code);
|
|
237
253
|
s.prepend(bootImport);
|
package/dist/index.js
CHANGED
|
@@ -193,8 +193,24 @@ function boot(options = {}) {
|
|
|
193
193
|
const bootImport = `globalThis.__astroscope_server_url = import.meta.url;
|
|
194
194
|
import * as __boot from './${bootChunkName}';
|
|
195
195
|
const __bootContext = { dev: false, host: process.env.HOST ?? '${host}', port: process.env.PORT ? Number(process.env.PORT) : ${port} };
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
try {
|
|
197
|
+
await __boot.onStartup?.(__bootContext);
|
|
198
|
+
} catch (err) {
|
|
199
|
+
console.error('[boot] startup failed:', err);
|
|
200
|
+
try { await __boot.onShutdown?.(__bootContext); } catch {}
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
if (__boot.onShutdown) {
|
|
204
|
+
process.on('SIGTERM', async () => {
|
|
205
|
+
try {
|
|
206
|
+
await __boot.onShutdown(__bootContext);
|
|
207
|
+
process.exit(0);
|
|
208
|
+
} catch (err) {
|
|
209
|
+
console.error('[boot] shutdown failed:', err);
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
198
214
|
`;
|
|
199
215
|
const s = new MagicString(entryChunk.code);
|
|
200
216
|
s.prepend(bootImport);
|
package/dist/warmup.cjs
CHANGED
|
@@ -61,7 +61,10 @@ async function warmup() {
|
|
|
61
61
|
const absolutePath = (0, import_node_path.resolve)(serverDir, mod);
|
|
62
62
|
return (0, import_node_url.pathToFileURL)(absolutePath).href;
|
|
63
63
|
});
|
|
64
|
-
const results = await Promise.allSettled(resolvedModules.map((mod) => import(
|
|
64
|
+
const results = await Promise.allSettled(resolvedModules.map((mod) => import(
|
|
65
|
+
/* @vite-ignore */
|
|
66
|
+
mod
|
|
67
|
+
)));
|
|
65
68
|
const success = [];
|
|
66
69
|
const failed = [];
|
|
67
70
|
for (let i = 0; i < results.length; i++) {
|
package/dist/warmup.js
CHANGED
|
@@ -36,7 +36,10 @@ async function warmup() {
|
|
|
36
36
|
const absolutePath = resolve(serverDir, mod);
|
|
37
37
|
return pathToFileURL(absolutePath).href;
|
|
38
38
|
});
|
|
39
|
-
const results = await Promise.allSettled(resolvedModules.map((mod) => import(
|
|
39
|
+
const results = await Promise.allSettled(resolvedModules.map((mod) => import(
|
|
40
|
+
/* @vite-ignore */
|
|
41
|
+
mod
|
|
42
|
+
)));
|
|
40
43
|
const success = [];
|
|
41
44
|
const failed = [];
|
|
42
45
|
for (let i = 0; i < results.length; i++) {
|