diff --git a/primary/src/app.ts b/primary/src/app.ts index 70d6017c..ea2056b3 100644 --- a/primary/src/app.ts +++ b/primary/src/app.ts @@ -107,6 +107,7 @@ app.set('views', path.join(__dirname, '..', 'views')); app.set('view engine', 'pug'); app.use(express.static(path.join(__dirname, '..', 'public'))); +// @ts-ignore 2025-01-17, M.O'C: TODO Jordan look at this app.use(favicon(path.join(__dirname, '..', 'public', 'icon-32.png'))); app.disable('x-powered-by'); @@ -141,6 +142,7 @@ const clientPromise: Promise = new Promise((resolve, reject) => { }); }); }); +// @ts-ignore 2025-01-17, M.O'C: TODO Jordan look at this app.use(session({ secret: 'marcus night', saveUninitialized: false, // don't create session until something stored @@ -161,10 +163,12 @@ app.use(session({ })); //User agent for logging +// @ts-ignore 2025-01-17, M.O'C: TODO Jordan look at this app.use(useragent.express()); //Passport setup (user authentication) require('./helpers/passport-config'); +// @ts-ignore 2025-01-17, M.O'C: TODO Jordan look at this app.use(passport.initialize()); app.use(passport.session()); diff --git a/scripts/uploadversion.js b/scripts/uploadversion.js index b2ae02d8..09bbfc35 100644 --- a/scripts/uploadversion.js +++ b/scripts/uploadversion.js @@ -73,6 +73,17 @@ console.log(`alias=${alias} functionName=${functionName} folder=${folder}`); // file_system.mkdirSync(folderPath); //} +// lambda.getFunctionConfiguration({FunctionName: functionName}).promise() +// .then(result => { +// console.log(result); +// if (result.state === 'Failed') { +// throw 'Lambda resource update failed'; +// } +// if (result.state === 'Pending') { +// throw 'Pending'; +// } +// }); + makeZip(folder, (err, zipBuffer) => { if (err) { throw err; @@ -144,7 +155,7 @@ function updateCode(zipBuffer, cb) { else { console.log(`Uploaded function code:\n\t FunctionName=${data.FunctionName}\n\t Role=${data.Role}\n\t CodeSha256=${data.CodeSha256}`); - publishVersion(data, time, cb); + publishVersion(data, time, cb).catch(function (err) { console.log(err); }); } }); } @@ -156,7 +167,7 @@ async function publishVersion(data, time, cb) { console.log('Waiting for function update to be complete...'); - await waitUntilNotPending(lambda, functionName, 1000, 5); + await waitUntilNotPending(lambda, functionName, 2000, 10); console.log('Publishing new version...'); var params = { @@ -214,19 +225,20 @@ async function waitUntilNotPending(lambda, functionName, timeout, retries) { return retry( () => { return lambda.getFunctionConfiguration({FunctionName: functionName}).promise() - .then(result => { - if (result.state === 'Failed') { + .then(result => { + //console.log(result); + if (result.LastUpdateStatus === 'Failed') { throw 'Lambda resource update failed'; } - if (result.state === 'Pending') { - throw 'Pending'; + if (result.LastUpdateStatus === 'InProgress') { + throw 'InProgress'; } }); }, timeout, retries, - failure => failure === 'Pending', - () => console.log('Lambda function is in Pending state, waiting...'), + failure => failure === 'InProgress', + () => console.log('Lambda function is in InProgress state, waiting...'), ); }