From fa0d4a7a5b95cd81d4268a8e6e4149a8bfbe9e18 Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Sun, 17 Dec 2023 04:35:18 -0800 Subject: [PATCH] fix: change to maintenance mode if instance does not launch --- src/services/InstanceService/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/services/InstanceService/index.ts b/src/services/InstanceService/index.ts index a7b4da3f..732f7a45 100644 --- a/src/services/InstanceService/index.ts +++ b/src/services/InstanceService/index.ts @@ -259,6 +259,7 @@ export const instanceService = mkSingleton( const db = await sqliteService.getDatabase( INSTANCE_DATA_DB(instance.id), ) + userInstanceLogger.info(`Syncing admin login`) await db(`_admins`) .insert({ id, email, tokenKey, passwordHash }) .onConflict('id') @@ -297,15 +298,17 @@ export const instanceService = mkSingleton( }, version, }) + return cp } catch (e) { warn(`Error spawning: ${e}`) + await updateInstance(instance.id, { + maintenance: true, + }) userInstanceLogger.error( - `Could not launch PocketBase ${instance.version}. Please review your instance logs at https://app.pockethost.io/app/instances/${instance.id} or contact support at https://pockethost.io/support`, - ) - throw new Error( - `Could not launch PocketBase ${instance.version}. Please review your instance logs at https://app.pockethost.io/app/instances/${instance.id} or contact support at https://pockethost.io/support`, + `Could not launch PocketBase ${instance.version}. Instance has been placed in maintenace mode. Please review your instance logs at https://app.pockethost.io/app/instances/${instance.id} or contact support at https://pockethost.io/support`, ) + throw new Error(`Maintenance mode`) } })() const { pid: _pid, exitCode } = childProcess