mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 11:30:43 +00:00
catch and log archive failure to prevent server crash
This commit is contained in:
+10
-6
@@ -4,10 +4,14 @@ import { Storage } from '@google-cloud/storage';
|
||||
const storage = new Storage();
|
||||
|
||||
export async function archive(gameRecord: GameRecord) {
|
||||
console.log(`writing game ${gameRecord.id} to gcs`)
|
||||
const bucket = storage.bucket("openfront-games");
|
||||
const file = bucket.file(gameRecord.id);
|
||||
await file.save(JSON.stringify(GameRecordSchema.parse(gameRecord)), {
|
||||
contentType: 'application/json'
|
||||
});
|
||||
try {
|
||||
console.log(`writing game ${gameRecord.id} to gcs`)
|
||||
const bucket = storage.bucket("openfront-games");
|
||||
const file = bucket.file(gameRecord.id);
|
||||
await file.save(JSON.stringify(GameRecordSchema.parse(gameRecord)), {
|
||||
contentType: 'application/json'
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(`error writing to gcs: ${error}`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user