barsa ff099525ca Update SHA256 checksums, enhance BFF development scripts, and improve Salesforce connection handling
- Updated SHA256 checksums for the latest portal backend and frontend tar.gz files to reflect new builds.
- Introduced a new development script (`dev-watch.sh`) for the BFF application to streamline TypeScript building and aliasing during development.
- Refactored the `package.json` scripts in the BFF application to improve development workflow and added new watch commands.
- Enhanced the Salesforce connection service to support private key handling via environment variables, improving security and flexibility in configuration.
2025-12-12 18:44:26 +09:00

94 lines
3.0 KiB
TypeScript

import { Logger } from "@nestjs/common";
import type { INestApplication } from "@nestjs/common";
import { bootstrap } from "./app/bootstrap.js";
const logger = new Logger("Main");
let app: INestApplication | null = null;
const signals: NodeJS.Signals[] = ["SIGINT", "SIGTERM"];
for (const signal of signals) {
process.once(signal, () => {
void (async () => {
logger.log(`Received ${signal}. Closing Nest application...`);
// #region agent log (hypothesis S1)
fetch("http://127.0.0.1:7242/ingest/a683e422-cfe7-4556-a583-809fbfbeeb4a", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
sessionId: "debug-session",
runId: "run1",
hypothesisId: "S1",
location: "apps/bff/src/main.ts:signalHandler(entry)",
message: "Process signal handler invoked",
data: { signal, pid: process.pid, appInitialized: !!app },
timestamp: Date.now(),
}),
}).catch(() => {});
// #endregion
if (!app) {
logger.warn("Nest application not initialized. Exiting immediately.");
process.exit(0);
return;
}
try {
// #region agent log (hypothesis S1)
fetch("http://127.0.0.1:7242/ingest/a683e422-cfe7-4556-a583-809fbfbeeb4a", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
sessionId: "debug-session",
runId: "run1",
hypothesisId: "S1",
location: "apps/bff/src/main.ts:signalHandler(beforeClose)",
message: "Calling app.close()",
data: { signal, pid: process.pid },
timestamp: Date.now(),
}),
}).catch(() => {});
// #endregion
await app.close();
logger.log("Nest application closed gracefully.");
} catch (error) {
const resolvedError = error as Error;
logger.error(
`Error during Nest application shutdown: ${resolvedError.message}`,
resolvedError.stack
);
} finally {
// #region agent log (hypothesis S1)
fetch("http://127.0.0.1:7242/ingest/a683e422-cfe7-4556-a583-809fbfbeeb4a", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
sessionId: "debug-session",
runId: "run1",
hypothesisId: "S1",
location: "apps/bff/src/main.ts:signalHandler(exit)",
message: "Exiting process after shutdown handler",
data: { signal, pid: process.pid },
timestamp: Date.now(),
}),
}).catch(() => {});
// #endregion
process.exit(0);
}
})();
});
}
void bootstrap()
.then(startedApp => {
app = startedApp;
})
.catch(error => {
const resolvedError = error as Error;
logger.error(
`Failed to bootstrap the Nest application: ${resolvedError.message}`,
resolvedError.stack
);
process.exit(1);
});