move turn secret generation

This commit is contained in:
Girish Ramakrishnan
2021-11-16 22:37:42 -08:00
parent 132c1872f4
commit b7c5c99301
2 changed files with 6 additions and 6 deletions
+6 -2
View File
@@ -919,8 +919,12 @@ async function startTurn(existingInfra) {
const memory = system.getMemoryAllocation(memoryLimit);
const realm = settings.dashboardFqdn();
const turnSecret = await blobs.get(blobs.ADDON_TURN_SECRET);
if (!turnSecret) throw new BoxError(BoxError.ADDONS_ERROR, 'Turn secret is missing');
let turnSecret = await blobs.get(blobs.ADDON_TURN_SECRET);
if (!turnSecret) {
debug('startTurn: generting turn secret');
turnSecret = 'a' + crypto.randomBytes(15).toString('hex'); // prefix with a to ensure string starts with a letter
await blobs.set(blobs.ADDON_TURN_SECRET, Buffer.from(turnSecret));
}
const readOnly = !serviceConfig.recoveryMode ? '--read-only' : '';
const cmd = serviceConfig.recoveryMode ? '/bin/bash -c \'echo "Debug mode. Sleeping" && sleep infinity\'' : '';