IDEMPIERE-3383 Schedule process: always recalculate sleep time before start
This commit is contained in:
parent
d12e72aec3
commit
2b18e84428
|
@ -103,6 +103,28 @@ public abstract class AdempiereServer implements Runnable
|
|||
return Env.getCtx();
|
||||
} // getCtx
|
||||
|
||||
public void recalculateSleepMS()
|
||||
{
|
||||
if (p_model instanceof PO)
|
||||
{
|
||||
PO po = (PO) p_model;
|
||||
po.load(null);
|
||||
}
|
||||
m_sleepMS = 0;
|
||||
m_nextWork = 0;
|
||||
|
||||
Timestamp lastRun = new Timestamp(System.currentTimeMillis());
|
||||
m_nextWork = MSchedule.getNextRunMS(lastRun.getTime(),
|
||||
p_model.getScheduleType(), p_model.getFrequencyType(),
|
||||
p_model.getFrequency(), p_model.getCronPattern());
|
||||
|
||||
m_sleepMS = m_nextWork - lastRun.getTime();
|
||||
if (log.isLoggable(Level.INFO)) log.info(" Next run: " + new Timestamp(m_nextWork) + " sleep " + m_sleepMS);
|
||||
//
|
||||
p_model.setDateNextRun(new Timestamp(m_nextWork));
|
||||
p_model.saveEx();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the sleepMS.
|
||||
*/
|
||||
|
|
|
@ -237,6 +237,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
|
|||
try
|
||||
{
|
||||
// replace
|
||||
server.getServer().recalculateSleepMS();
|
||||
server.start();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
Loading…
Reference in New Issue