diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js --- a/keyserver/src/keyserver.js +++ b/keyserver/src/keyserver.js @@ -47,7 +47,10 @@ import { initENSCache } from './utils/ens-cache.js'; import { initFCCache } from './utils/fc-cache.js'; import { getContentSigningKey } from './utils/olm-utils.js'; -import { isPrimaryNode } from './utils/primary-secondary-utils.js'; +import { + isPrimaryNode, + isSecondaryNode, +} from './utils/primary-secondary-utils.js'; import { getRunServerConfig } from './utils/server-utils.js'; import { prefetchAllURLFacts, @@ -131,20 +134,32 @@ } else { // Allow login to be optional until staging environment is available try { - // We await here to ensure that the keyserver has been provisioned a - // commServicesAccessToken. In the future, this will be necessary for - // many keyserver operations. - const identityInfo = await verifyUserLoggedIn(); + await (async () => { + // Should not be run by Landing or WebApp nodes + if (!isPrimaryNode && !isSecondaryNode) { + return; + } + + // We await here to ensure that the keyserver has been provisioned a + // commServicesAccessToken. In the future, this will be necessary for + // many keyserver operations. + const identityInfo = await verifyUserLoggedIn(); + + if (!isPrimaryNode) { + return; + } - if (isPrimaryNode) { // We don't await here, as Tunnelbroker communication is not needed // for normal keyserver behavior yet. In addition, this doesn't // return information useful for other keyserver functions. ignorePromiseRejections(createAndMaintainTunnelbrokerWebsocket(null)); - if (process.env.NODE_ENV === 'development') { - await createAuthoritativeKeyserverConfigFiles(identityInfo.userId); + + if (process.env.NODE_ENV !== 'development') { + return; } - } + + await createAuthoritativeKeyserverConfigFiles(identityInfo.userId); + })(); } catch (e) { console.warn( 'Failed identity login. Login optional until staging environment is available', diff --git a/keyserver/src/utils/primary-secondary-utils.js b/keyserver/src/utils/primary-secondary-utils.js --- a/keyserver/src/utils/primary-secondary-utils.js +++ b/keyserver/src/utils/primary-secondary-utils.js @@ -3,3 +3,7 @@ export const isPrimaryNode: boolean = process.env.COMM_NODE_ROLE ? process.env.COMM_NODE_ROLE === 'primary' : true; + +export const isSecondaryNode: boolean = process.env.COMM_NODE_ROLE + ? process.env.COMM_NODE_ROLE === 'secondary' + : false;