Skip to content

Commit

Permalink
Merge pull request #2873 from SCADA-LTS/fix/#2083_Catching_an_excepti…
Browse files Browse the repository at this point in the history
…on_in_an_application_initialization_method

#2083 Catching an exception in an application initialization method:
  • Loading branch information
Limraj authored May 10, 2024
2 parents ae54faf + 7167519 commit 5bba7ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/com/serotonin/mango/MangoContextListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public class MangoContextListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent evt) {
try {
initialized(evt);
// Notify the event manager of the startup.
SystemEventType.raiseEvent(new SystemEventType(
SystemEventType.TYPE_SYSTEM_STARTUP), System
.currentTimeMillis(), false, new LocalizableMessage(
"event.system.startup"));
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
throw ex;
Expand Down Expand Up @@ -163,11 +168,7 @@ private void initialized(ServletContextEvent evt) {
reportsInitialize();
maintenanceInitialize();

// Notify the event manager of the startup.
SystemEventType.raiseEvent(new SystemEventType(
SystemEventType.TYPE_SYSTEM_STARTUP), System
.currentTimeMillis(), false, new LocalizableMessage(
"event.system.startup"));



try {
Expand Down
9 changes: 9 additions & 0 deletions src/com/serotonin/mango/rt/maint/WorkItemMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
import com.serotonin.mango.Common;
import com.serotonin.timer.FixedRateTrigger;
import com.serotonin.timer.TimerTask;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.scada_lts.monitor.type.IntegerMonitor;

public class WorkItemMonitor extends TimerTask {

private static final Log LOG = LogFactory.getLog(WorkItemMonitor.class);
private static final long TIMEOUT = 1000 * 10; // Run every ten seconds.

/**
Expand Down Expand Up @@ -40,6 +44,11 @@ private WorkItemMonitor() {

@Override
public void run(long fireTime) {
if(Common.ctx == null || Common.ctx.getBackgroundProcessing() == null) {
LOG.warn("Scada-LTS context terminated");
return;
}

BackgroundProcessing bp = Common.ctx.getBackgroundProcessing();

mediumPriorityServiceQueueSize.setValue(bp.getMediumPriorityServiceQueueSize());
Expand Down

0 comments on commit 5bba7ad

Please sign in to comment.