IDEMPIERE-3670 Schedule process: always recalculate sleep time before start and startAll. Fix context is lost error.

This commit is contained in:
Heng Sin Low 2018-04-06 13:41:13 +08:00
parent 3d675e132c
commit 77e30d8c2c
1 changed files with 7 additions and 0 deletions

View File

@ -227,6 +227,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
continue;
// Do start
// replace
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, server.getServer().getModel().getAD_Client_ID());
server.getServer().recalculateSleepMS();
server.start();
}
@ -235,6 +236,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
log.log(Level.SEVERE, "Server: " + server, e);
}
} // for all servers
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, 0);
// Final Check
int noRunning = 0;
@ -281,6 +283,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
try
{
// replace
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, server.getServer().getModel().getAD_Client_ID());
server.getServer().recalculateSleepMS();
server.start();
}
@ -289,6 +292,10 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
log.log(Level.SEVERE, "Server=" + serverID, e);
return false;
}
finally
{
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, 0);
}
if (log.isLoggable(Level.INFO)) log.info(server.toString());
return (server.scheduleFuture != null && !server.scheduleFuture.isDone());
} // startIt