IDEMPIERE-3823 Schedule without Schedule Type is running wild / implemented to run once on reboot

This commit is contained in:
Carlos Ruiz 2018-11-19 10:59:58 -02:00
parent 28171cda7a
commit 620b9715bb
2 changed files with 11 additions and 2 deletions

View File

@ -297,10 +297,17 @@ public abstract class AdempiereServer implements Runnable
p_model.getFrequency(), p_model.getCronPattern());
m_sleepMS = m_nextWork - now;
if (m_nextWork == 0) {
m_sleepMS = 0;
}
if (log.isLoggable(Level.INFO)) log.info(" Next run: " + new Timestamp(m_nextWork) + " sleep " + m_sleepMS);
//
p_model.setDateLastRun(lastRun);
if (m_nextWork == 0) {
p_model.setDateNextRun(null);
} else {
p_model.setDateNextRun(new Timestamp(m_nextWork));
}
p_model.saveEx();
} // run

View File

@ -577,7 +577,9 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
public void run() {
if (server.isSleeping()) {
server.run();
if (server.getSleepMS() != 0) {
scheduleFuture = Adempiere.getThreadPoolExecutor().schedule(this, server.getSleepMS(), TimeUnit.MILLISECONDS);
}
} else {
//server busy, try again after one minute
scheduleFuture = Adempiere.getThreadPoolExecutor().schedule(this, 60 * 1000, TimeUnit.MILLISECONDS);