fixed service stop working
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s
This commit is contained in:
parent
759e69d44d
commit
e69320005c
2 changed files with 19 additions and 1 deletions
18
src/app.ts
18
src/app.ts
|
|
@ -21,6 +21,24 @@ import { DateSerializer } from "./interfaces/date-serializer";
|
||||||
import { initWebSocket } from "./services/webSocket";
|
import { initWebSocket } from "./services/webSocket";
|
||||||
import { RetirementService } from "./services/RetirementService";
|
import { RetirementService } from "./services/RetirementService";
|
||||||
|
|
||||||
|
// ── Process-level safety nets ──────────────────────────────────────────────
|
||||||
|
// ตาข่ายกัน service ตายจาก promise ที่ reject แล้วไม่ถูกจับ / exception ที่หลุด
|
||||||
|
// ออกมา (เช่น bug เรียก async โดยไม่ await ใน PermissionController).
|
||||||
|
// ลงทะเบียนไว้ให้เร็วที่สุด ก่อนที่ main() จะเริ่มทำงาน
|
||||||
|
process.on("unhandledRejection", (reason) => {
|
||||||
|
console.error(
|
||||||
|
"[APP][unhandledRejection] A promise was rejected but never caught:",
|
||||||
|
reason,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
process.on("uncaughtException", (err) => {
|
||||||
|
// คง service ไว้เพื่อ availability สูงสุด
|
||||||
|
// หมายเหตุ: process อาจอยู่ในสถานะไม่สม่ำเสมอ ควร monitor log นี้และ restart
|
||||||
|
// ในช่วงเวลาที่เหมาะสม ถ้าต้องการ crash-on-error ให้เปลี่ยนเป็น graceful
|
||||||
|
// shutdown + process.exit(1) ตรงนี้
|
||||||
|
console.error("[APP][uncaughtException] An exception escaped all handlers:", err);
|
||||||
|
});
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await AppDataSource.initialize();
|
await AppDataSource.initialize();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -810,7 +810,7 @@ export class PermissionController extends Controller {
|
||||||
});
|
});
|
||||||
const getAsync = promisify(redisClient.get).bind(redisClient);
|
const getAsync = promisify(redisClient.get).bind(redisClient);
|
||||||
|
|
||||||
let org = this.PermissionOrg(request, system, action);
|
let org = await this.PermissionOrg(request, system, action);
|
||||||
let reply = await getAsync("user_" + id);
|
let reply = await getAsync("user_" + id);
|
||||||
if (reply != null) {
|
if (reply != null) {
|
||||||
reply = JSON.parse(reply);
|
reply = JSON.parse(reply);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue