refactor(server): added in serverCrash email
This commit is contained in:
@@ -15,6 +15,7 @@ import { monitorAlplaPurchase } from "./purchase/purchase.controller.js";
|
|||||||
import { setupSocketIORoutes } from "./socket.io/serverSetup.js";
|
import { setupSocketIORoutes } from "./socket.io/serverSetup.js";
|
||||||
import { baseSettingValidationCheck } from "./system/settingsBase.controller.js";
|
import { baseSettingValidationCheck } from "./system/settingsBase.controller.js";
|
||||||
import { createCronJob } from "./utils/croner.utils.js";
|
import { createCronJob } from "./utils/croner.utils.js";
|
||||||
|
import { sendEmail } from "./utils/sendEmail.utils.js";
|
||||||
|
|
||||||
const port = Number(process.env.PORT) || 3000;
|
const port = Number(process.env.PORT) || 3000;
|
||||||
export let systemSettings: Setting[] = [];
|
export let systemSettings: Setting[] = [];
|
||||||
@@ -62,6 +63,23 @@ const start = async () => {
|
|||||||
startNotifications();
|
startNotifications();
|
||||||
}, 5 * 1000);
|
}, 5 * 1000);
|
||||||
|
|
||||||
|
process.on("uncaughtException", async (err) => {
|
||||||
|
console.error("Uncaught Exception:", err);
|
||||||
|
//await closePool();
|
||||||
|
const emailData = {
|
||||||
|
email: "blake.matthes@alpla.com", // should be moved to the db so it can be reused.
|
||||||
|
subject: `${os.hostname()} has just encountered a crash.`,
|
||||||
|
template: "serverCrash",
|
||||||
|
context: {
|
||||||
|
error: err,
|
||||||
|
plant: `${os.hostname()}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
await sendEmail(emailData);
|
||||||
|
//process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
server.listen(port, async () => {
|
server.listen(port, async () => {
|
||||||
log.info(
|
log.info(
|
||||||
`Listening on http://${os.hostname()}:${port}${baseUrl}, logging in ${process.env.LOG_LEVEL}, current ENV ${process.env.NODE_ENV ? process.env.NODE_ENV : "development"}`,
|
`Listening on http://${os.hostname()}:${port}${baseUrl}, logging in ${process.env.LOG_LEVEL}, current ENV ${process.env.NODE_ENV ? process.env.NODE_ENV : "development"}`,
|
||||||
|
|||||||
35
backend/utils/mailViews/serverCrash.hbs
Normal file
35
backend/utils/mailViews/serverCrash.hbs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
{{!--<title>Order Summary</title> --}}
|
||||||
|
{{> styles}}
|
||||||
|
<style>
|
||||||
|
pre {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
color: #d63384;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{{!-- <link rel="stylesheet" href="styles/styles.css" /> --}}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h3>{{plant}},<br/> Has encountered an unexpected error.</h1>
|
||||||
|
<p>
|
||||||
|
Please see below the stack error from the crash.
|
||||||
|
</p>
|
||||||
|
<hr/>
|
||||||
|
<div>
|
||||||
|
<h3>Error Message: </h3>
|
||||||
|
<p>{{error.message}}</p>
|
||||||
|
</div>
|
||||||
|
<hr/>
|
||||||
|
<div>
|
||||||
|
<h3>Stack trace</h3>
|
||||||
|
<pre>{{{error.stack}}}</pre>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user