scripting-cli 1.1.11 → 1.1.12
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/start_server.js +21 -6
- package/package.json +1 -1
- package/src/start_server.ts +26 -6
package/dist/start_server.js
CHANGED
|
@@ -37,16 +37,31 @@ function startServer({ port, noAutoOpen }) {
|
|
|
37
37
|
const service = bonjour.publish({
|
|
38
38
|
name: 'Scripting-service',
|
|
39
39
|
type: 'http',
|
|
40
|
-
port: PORT
|
|
40
|
+
port: PORT,
|
|
41
|
+
host: 'scripting-service.local',
|
|
41
42
|
});
|
|
42
|
-
|
|
43
|
+
// Register bonjour service error handler
|
|
44
|
+
service.on('error', err => {
|
|
45
|
+
console.error('Bonjour service error:', err);
|
|
46
|
+
});
|
|
47
|
+
['SIGINT', 'SIGTERM'].forEach(sig => process.once(sig, gracefulShutdown));
|
|
48
|
+
// Handle uncaught exceptions
|
|
49
|
+
process.on('uncaughtException', err => {
|
|
50
|
+
console.error('Uncaught exception:', err);
|
|
51
|
+
gracefulShutdown();
|
|
52
|
+
});
|
|
53
|
+
function gracefulShutdown() {
|
|
54
|
+
console.log('Shutting down Bonjour…');
|
|
43
55
|
service.stop(() => {
|
|
44
56
|
bonjour.unpublishAll(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
// wait for 500ms,let goodbye message be sent completely
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
bonjour.destroy();
|
|
60
|
+
console.log('Bonjour services have been shut down properly.');
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}, 500);
|
|
48
63
|
});
|
|
49
64
|
});
|
|
50
|
-
}
|
|
65
|
+
}
|
|
51
66
|
});
|
|
52
67
|
}
|
package/package.json
CHANGED
package/src/start_server.ts
CHANGED
|
@@ -46,18 +46,38 @@ export function startServer({ port, noAutoOpen }: {
|
|
|
46
46
|
const service = bonjour.publish({
|
|
47
47
|
name: 'Scripting-service',
|
|
48
48
|
type: 'http',
|
|
49
|
-
port: PORT
|
|
49
|
+
port: PORT,
|
|
50
|
+
host: 'scripting-service.local',
|
|
50
51
|
});
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
// Register bonjour service error handler
|
|
54
|
+
service.on('error', err => {
|
|
55
|
+
console.error('Bonjour service error:', err);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
['SIGINT', 'SIGTERM'].forEach(sig =>
|
|
59
|
+
process.once(sig, gracefulShutdown)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// Handle uncaught exceptions
|
|
63
|
+
process.on('uncaughtException', err => {
|
|
64
|
+
console.error('Uncaught exception:', err);
|
|
65
|
+
gracefulShutdown();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
function gracefulShutdown() {
|
|
69
|
+
console.log('Shutting down Bonjour…');
|
|
53
70
|
service.stop(() => {
|
|
54
71
|
bonjour.unpublishAll(() => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
72
|
+
// wait for 500ms,let goodbye message be sent completely
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
bonjour.destroy();
|
|
75
|
+
console.log('Bonjour services have been shut down properly.');
|
|
76
|
+
process.exit(0);
|
|
77
|
+
}, 500);
|
|
58
78
|
});
|
|
59
79
|
});
|
|
60
|
-
}
|
|
80
|
+
}
|
|
61
81
|
|
|
62
82
|
});
|
|
63
83
|
}
|