Skip to content

Commit

Permalink
Fixes to deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ardaglash authored and JL102 committed Jan 24, 2025
1 parent adfa2bf commit 398ca86
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
4 changes: 4 additions & 0 deletions primary/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -141,6 +142,7 @@ const clientPromise: Promise<MongoClient> = 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
Expand All @@ -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());

Expand Down
28 changes: 20 additions & 8 deletions scripts/uploadversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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); });
}
});
}
Expand All @@ -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 = {
Expand Down Expand Up @@ -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...'),
);
}

Expand Down

0 comments on commit 398ca86

Please sign in to comment.