Merged PR 1618: updated gitignore,package lock for node 20 pipeline
updated gitignore,package lock for node 20 pipeline Related work items: #12956
This commit is contained in:
+2
-2
@@ -16,8 +16,8 @@ yarn-error.log*
|
||||
.yarn
|
||||
|
||||
#lock files
|
||||
yarn.lock
|
||||
package-lock.json
|
||||
# yarn.lock
|
||||
# package-lock.json
|
||||
|
||||
tmp
|
||||
|
||||
|
||||
Generated
+11285
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -7,9 +7,10 @@
|
||||
"debugdev": "NODE_OPTIONS='--inspect' next dev",
|
||||
"dev:app": "node ./server/server.js",
|
||||
"build": "NODE_ENV=production node_modules/next/dist/bin/next build",
|
||||
"start2": "NODE_ENV=production node ./server/server.js",
|
||||
"start2": "NODE_ENV=production node server.js",
|
||||
"start": "NODE_ENV=production node_modules/next/dist/bin/next start",
|
||||
"lint": "next lint"
|
||||
"lint": "next lint",
|
||||
"prisma:generate": "prisma generate"
|
||||
},
|
||||
"browser": {
|
||||
"child_process": false
|
||||
@@ -48,8 +49,7 @@
|
||||
"moment": "^2.29.4",
|
||||
"multiparty": "^4.2.3",
|
||||
"mysql": "^2.18.1",
|
||||
"nanoid": "^3.2.0",
|
||||
"next": "14.1.2",
|
||||
"next": "^14.2.28",
|
||||
"next-auth": "^4.24.4",
|
||||
"next-build-id": "^3.0.0",
|
||||
"next-connect": "^0.12.2",
|
||||
@@ -104,4 +104,4 @@
|
||||
"eslint-plugin-jsdoc": "^48.2.3",
|
||||
"prisma": "^5.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import Document, { Html, Head, Main, NextScript } from "next/document";
|
||||
import SkipLink from "../components/skiplink";
|
||||
import { Tracking, TrackingNoScript } from "../components/tracking";
|
||||
import { nanoid } from "nanoid";
|
||||
//import { nanoid } from "nanoid";
|
||||
import { setCookie } from "nookies";
|
||||
import Script from "next/script";
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ const appInsights = require("applicationinsights");
|
||||
|
||||
const initAppInsights = (instrumentationKey) => {
|
||||
if (!instrumentationKey) {
|
||||
console.log("App Insights not configured.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -13,6 +14,7 @@ const initAppInsights = (instrumentationKey) => {
|
||||
.setSendLiveMetrics(true)
|
||||
.start();
|
||||
|
||||
console.log("App Insights enabled.");
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -24,6 +26,8 @@ const startServer = async (config) => {
|
||||
};
|
||||
|
||||
const app = next(serverOptions);
|
||||
await app.prepare(); // prepare BEFORE starting the server
|
||||
|
||||
const handleNextRequests = app.getRequestHandler();
|
||||
|
||||
const srv = createServer((req, res) => {
|
||||
@@ -38,22 +42,28 @@ const startServer = async (config) => {
|
||||
});
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
// This code catches EADDRINUSE error if the port is already in use
|
||||
srv.on("error", reject);
|
||||
srv.on("listening", () => resolve());
|
||||
srv.listen(config.port, config.hostname);
|
||||
});
|
||||
|
||||
// It's up to caller to run `app.prepare()`, so it can notify that the server
|
||||
// is listening before starting any intensive operations.
|
||||
// Graceful shutdown handling
|
||||
process.on("SIGTERM", () => {
|
||||
console.log("Received SIGTERM, shutting down gracefully...");
|
||||
srv.close(() => {
|
||||
console.log("Server closed.");
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
||||
|
||||
return app;
|
||||
};
|
||||
|
||||
// App configuration
|
||||
const startTime = Date.now();
|
||||
|
||||
const serverConfig = {
|
||||
hostname: "localhost",
|
||||
port: process.env.PORT || 3000,
|
||||
hostname: "0.0.0.0", // Required for Azure App Service
|
||||
port: parseInt(process.env.PORT, 10) || 3000,
|
||||
env: process.env.APP_ENV || process.env.NODE_ENV || "production",
|
||||
useAppInsights: initAppInsights(
|
||||
process.env.NEXT_PUBLIC_APPINSIGHTS_INSTRUMENTATIONKEY
|
||||
@@ -61,24 +71,20 @@ const serverConfig = {
|
||||
};
|
||||
|
||||
startServer(serverConfig)
|
||||
.then(async (app) => {
|
||||
.then(() => {
|
||||
console.log(
|
||||
`started server on host ${serverConfig.hostname}, port ${serverConfig.port}, env ${serverConfig.env}`
|
||||
`Server ready on http://${serverConfig.hostname}:${serverConfig.port} [${serverConfig.env}]`
|
||||
);
|
||||
|
||||
if (serverConfig.useAppInsights) {
|
||||
const duration = Date.now() - startTime;
|
||||
|
||||
appInsights.defaultClient.trackMetric({
|
||||
name: "server startup time",
|
||||
name: "Server Startup Time",
|
||||
value: duration,
|
||||
});
|
||||
}
|
||||
|
||||
await app.prepare();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(err);
|
||||
|
||||
.catch((err) => {
|
||||
console.error("Server failed to start:", err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user