Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
revert back change to the timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Stephanie <[email protected]>
  • Loading branch information
Stephanie authored and Rajiv Nathan committed Nov 22, 2019
1 parent 671db59 commit 2016be2
Showing 1 changed file with 1 addition and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const buildRequiredMap = new Map();

const pingInterval = 10000;
const inTransitPingInterval = 2000;
const pingCountMap = new Map();

// Keep track of project status. The type parameter is used to determine the type of the status
// such as application state or build status.
Expand Down Expand Up @@ -443,30 +442,16 @@ function pingInTransitApplications(): void {
const oldMsg = appStateMap.get(projectID).msg;
let newState = oldState;
let newMsg = stateInfo.error;
let pingCount = pingCountMap.get(projectID);
if (newMsg) { newMsg = newMsg.toString(); } // Convert from Error to string
if (stateInfo.hasOwnProperty("isAppUp")) {
if (oldState === AppState.starting && stateInfo.isAppUp) {
newState = (stateInfo.isAppUp && projectInfo.sentProjectInfo) ? AppState.started : oldState;
} else if (oldState === AppState.stopping && !stateInfo.isAppUp) {
newState = AppState.stopped;
} else if ( oldState === AppState.starting ) {
// ping timeout, increment pingCount
if (pingCountMap.get(projectID)) {
pingCount++;
pingCountMap.set(projectID, pingCount);
} else {
pingCountMap.set(projectID, 1);
pingCount = 1;
}
}
} else if (oldState === AppState.stopping && newMsg) {
newState = AppState.stopped;
}
if (pingCount >= 10) {
newState = AppState.stopped;
newMsg = "projectStatusController.pingTimeout";
}

if (newState === AppState.started) {
appStateMap.set(projectID, new ProjectState(newState, newMsg));
Expand All @@ -481,7 +466,7 @@ function pingInTransitApplications(): void {
}

// Update the state only if it has changed
if (newState !== oldState || ((newState === AppState.starting) && pingCount >= 10)) {
if (newState !== oldState) {
logger.logProjectInfo("pingInTransitApplications: Application state for project " + projectID + " has changed from " + oldState + " to " + newState, projectID);
const data: any = {
projectID: projectID,
Expand All @@ -496,7 +481,6 @@ function pingInTransitApplications(): void {
}

io.emitOnListener("projectStatusChanged", data);
pingCountMap.delete(projectID);
}
}
});
Expand Down

0 comments on commit 2016be2

Please sign in to comment.