@tiflis-io/tiflis-code-workstation 0.3.22 → 0.3.23

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/dist/main.js +13 -27
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -9189,19 +9189,6 @@ function handleAuthMessageViaTunnel(data, tunnelClient, authenticateClient, logg
9189
9189
  tunnelClient.send(JSON.stringify(errorResponse));
9190
9190
  }
9191
9191
  }
9192
- var emergencySignalCount = 0;
9193
- process.on("SIGINT", () => {
9194
- emergencySignalCount++;
9195
- console.log("\n[SIGINT received]");
9196
- if (emergencySignalCount >= 2) {
9197
- console.log("[Force exit on repeated Ctrl+C]");
9198
- process.exit(1);
9199
- }
9200
- });
9201
- process.on("SIGTERM", () => {
9202
- console.log("\n[SIGTERM received]");
9203
- process.exit(1);
9204
- });
9205
9192
  async function bootstrap() {
9206
9193
  const workstationVersion = getWorkstationVersion();
9207
9194
  const protocolVersion = getProtocolVersion();
@@ -9222,28 +9209,27 @@ async function bootstrap() {
9222
9209
  },
9223
9210
  "Starting workstation server"
9224
9211
  );
9212
+ let shutdownInProgress = false;
9213
+ let signalCount = 0;
9225
9214
  const registerSignalHandlers = (shutdown2) => {
9226
- let signalCount = 0;
9227
9215
  const handleSignal = (signal) => {
9228
9216
  signalCount++;
9229
- logger.info({ signal, count: signalCount }, "Signal received, initiating shutdown");
9230
- if (signalCount === 1) {
9231
- console.log("\nShutting down gracefully...");
9232
- shutdown2(signal).then(() => {
9233
- process.exit(0);
9234
- }).catch((error) => {
9235
- logger.error({ error }, "Error during shutdown");
9236
- process.exit(1);
9237
- });
9238
- } else {
9239
- console.log("\nForce exiting...");
9217
+ if (shutdownInProgress) {
9240
9218
  process.exit(1);
9241
9219
  }
9220
+ shutdownInProgress = true;
9221
+ logger.info({ signal, count: signalCount }, "Signal received");
9222
+ console.log("\nShutting down...");
9223
+ shutdown2(signal).catch((error) => {
9224
+ logger.error({ error }, "Shutdown error");
9225
+ }).finally(() => {
9226
+ process.exit(0);
9227
+ });
9242
9228
  };
9243
9229
  process.on("SIGTERM", () => handleSignal("SIGTERM"));
9244
9230
  process.on("SIGINT", () => handleSignal("SIGINT"));
9245
- process.on("unhandledRejection", (reason, promise) => {
9246
- logger.error({ reason, promise }, "Unhandled rejection");
9231
+ process.on("unhandledRejection", (reason) => {
9232
+ logger.error({ reason }, "Unhandled rejection");
9247
9233
  });
9248
9234
  process.on("uncaughtException", (error) => {
9249
9235
  logger.fatal({ error }, "Uncaught exception");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiflis-io/tiflis-code-workstation",
3
- "version": "0.3.22",
3
+ "version": "0.3.23",
4
4
  "description": "Workstation server for tiflis-code - manages agent sessions and terminal access",
5
5
  "author": "Roman Barinov <rbarinov@gmail.com>",
6
6
  "license": "FSL-1.1-NC",