Wrap admin user creation in a try/catch to provider better info in case of an error

This commit is contained in:
Andrew Kingston 2022-06-30 11:40:52 +01:00
parent f49e2886ca
commit e9d20abb0d
1 changed files with 14 additions and 9 deletions

View File

@ -121,15 +121,20 @@ module.exports = server.listen(env.PORT || 0, async () => {
) {
const checklist = await getChecklist()
if (!checklist?.adminUser?.checked) {
await createAdminUser(
env.BB_ADMIN_USER_EMAIL,
env.BB_ADMIN_USER_PASSWORD,
"default"
)
console.log(
"Admin account automatically created for",
env.BB_ADMIN_USER_EMAIL
)
try {
await createAdminUser(
env.BB_ADMIN_USER_EMAIL,
env.BB_ADMIN_USER_PASSWORD,
"default"
)
console.log(
"Admin account automatically created for",
env.BB_ADMIN_USER_EMAIL
)
} catch (e) {
logAlert("Error creating initial admin user. Exiting.", e)
shutdown()
}
}
}