From 2319e072ee3f54e66da1599fdab8460ac57f2d37 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 14 Jun 2021 13:02:37 -0700 Subject: [PATCH] Places: add configuration for interval for checking Place lastActivity timeout Tune times for inactivity and current info update activity. --- src/Entities/Places.ts | 2 +- src/config.ts | 6 ++++-- src/routes/api/maint/places.ts | 3 +-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Entities/Places.ts b/src/Entities/Places.ts index 451ba6c7..0bbe90f2 100755 --- a/src/Entities/Places.ts +++ b/src/Entities/Places.ts @@ -116,7 +116,7 @@ export function initPlaces(): void { await Places.updateEntityFields(aPlace, updates); }; // Logger.debug(`PlaceActivity: numPlaces=${numPlaces}, unhookedPlaces=${numUnhookedPlaces}, inactivePlaces=${numInactivePlaces}`); - }, 1000 * 58 ); + }, 1000 * Config['metaverse-server']['place-check-last-activity-seconds'] ); }; export const Places = { diff --git a/src/config.ts b/src/config.ts index 9e2ec6a9..de8897b3 100755 --- a/src/config.ts +++ b/src/config.ts @@ -61,8 +61,10 @@ export let Config = { 'connection-request-expiration-minutes': 60 * 24 * 4, // 4 days 'friend-request-expiration-minutes': 60 * 24 * 4, // 4 days - 'place-current-timeout-minutes': 60, // minutes until current place info is stale - 'place-inactive-timeout-minutes': 60*24*7, // minutes until place is considered inactive + 'place-current-timeout-minutes': 30, // minutes until current place info is stale + 'place-inactive-timeout-minutes': 60, // minutes until place is considered inactive + 'place-check-last-activity-seconds': (5*60)-5, // seconds between checks for Place lastActivity updates + // redirection URL used for initial domain token generation, // "METAVERSE_SERVER_URL" is replaced (from Config.metaverse.metaverse-server-url) // "DASHBOARD_URL" is replaced (from Config.metaverse.dashboard-url) diff --git a/src/routes/api/maint/places.ts b/src/routes/api/maint/places.ts index 2b79f87e..c08e8cc2 100644 --- a/src/routes/api/maint/places.ts +++ b/src/routes/api/maint/places.ts @@ -170,8 +170,7 @@ const procPlacesDeleteInactive: RequestHandler = async (req: Request, resp: Resp }; // Return a stream of PlaceEntity's that do not have a domain or a domain that isn't addressable async function *inactivePlaces(pPager: CriteriaFilter, pInfoer?: CriteriaFilter): AsyncGenerator { - const inactivePlaceTime = new Date(Date.now() - - (Config['metaverse-server']['place-inactive-timeout-minutes'] * 60 * 1000)); + const inactivePlaceTime = Places.dateWhenNotActive(); for await (const aPlace of Places.enumerateAsync(pPager, pInfoer)) { if (IsNotNullOrEmpty(aPlace.lastActivity) || aPlace.lastActivity < inactivePlaceTime) { yield aPlace;