@lazyapps/bootstrap 0.1.4 → 0.2.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.
- package/index.js +29 -4
- package/package.json +5 -4
package/index.js
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import { startCommandProcessor } from '@lazyapps/command-processor';
|
|
2
2
|
import { startReadModels } from '@lazyapps/readmodels';
|
|
3
3
|
import { getLogger } from '@lazyapps/logger';
|
|
4
|
+
import { trace, context } from '@opentelemetry/api';
|
|
5
|
+
|
|
6
|
+
const tracer = trace.getTracer('@lazyapps/bootstrap');
|
|
4
7
|
|
|
5
8
|
const log = getLogger('BS', 'INIT');
|
|
6
9
|
|
|
7
10
|
let signalHandlersInstalled = false;
|
|
11
|
+
|
|
8
12
|
const handleSignals = (server) => {
|
|
9
13
|
const handler = (signal) => {
|
|
10
14
|
log.info(`Signal ${signal} received`);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
// Force exit after 5s in case graceful shutdown hangs
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
log.warn('Forced exit after timeout');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}, 5000).unref();
|
|
20
|
+
import('@lazyapps/observability')
|
|
21
|
+
.then(({ shutdown }) => shutdown())
|
|
22
|
+
.catch(() => {})
|
|
23
|
+
.then(() => {
|
|
24
|
+
server.close(() => {
|
|
25
|
+
log.info('Server closed, exiting process');
|
|
26
|
+
process.exit(0);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
15
29
|
};
|
|
16
30
|
|
|
17
31
|
if (!signalHandlersInstalled) {
|
|
@@ -29,6 +43,15 @@ export function start({
|
|
|
29
43
|
changeNotifier,
|
|
30
44
|
svelte,
|
|
31
45
|
}) {
|
|
46
|
+
const startSpan = tracer.startSpan('lazyapps.bootstrap.start', {
|
|
47
|
+
attributes: {
|
|
48
|
+
'bootstrap.commands': !!commands,
|
|
49
|
+
'bootstrap.readModels': !!readModels,
|
|
50
|
+
'bootstrap.changeNotifier': !!changeNotifier,
|
|
51
|
+
'bootstrap.svelte': !!svelte,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
32
55
|
if (commands) {
|
|
33
56
|
log.debug('Starting command processor');
|
|
34
57
|
startCommandProcessor(correlationConfig, commands).then((server) => {
|
|
@@ -53,4 +76,6 @@ export function start({
|
|
|
53
76
|
startSvelteKit(correlationConfig, svelte);
|
|
54
77
|
});
|
|
55
78
|
}
|
|
79
|
+
|
|
80
|
+
startSpan.end();
|
|
56
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lazyapps/bootstrap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Composition orchestrator for LazyApps applications",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
"vitest": "^4.0.18"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@
|
|
36
|
-
"@lazyapps/
|
|
37
|
-
"@lazyapps/
|
|
35
|
+
"@opentelemetry/api": "^1.9.0",
|
|
36
|
+
"@lazyapps/command-processor": "^0.1.2",
|
|
37
|
+
"@lazyapps/logger": "^0.2.0",
|
|
38
|
+
"@lazyapps/readmodels": "^0.1.2"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"vite": ">=5.0.0",
|