Package com.acelet.s.watchdog

Source Code of com.acelet.s.watchdog.WatchdoggingDaemon

/* Copyright 1999-2008 Acelet.org. All rights reserved. GPL v2 license */
/** @author Wei Jiang */

package com.acelet.s.watchdog;

import java.io.*;
import java.sql.Connection;
import java.util.*;

import com.acelet.lib.Externals;
import com.acelet.lib.JavaVersionException;
import com.acelet.lib.Kit;
import com.acelet.lib.LoggingConstants;
import com.acelet.lib.LoggingTimeoutException;
import com.acelet.lib.Phrase;
import com.acelet.s.MailServerData;
import com.acelet.s.PrintInfo;
import com.acelet.s.chore.CandidateChore;
import com.acelet.s.chore.Chore;
import com.acelet.s.chore.ChoreText;
import com.acelet.s.chore.WorkingChore;
import com.acelet.s.scheduler.DirectTaskDatabaseConnection;
import com.acelet.s.scheduler.SchedulerProperties;

public class WatchdoggingDaemon extends Watchdogging {
  public WatchdoggingDaemon() {
  }

  protected void init() throws Exception {
    showLicense();
    new PrintInfo().printInfo();
    Externals.runningMode = Externals.RUNNING_MODE_COMMAND_LINE;
   
    MailServerData.init();
   
    String logAgentName = SchedulerProperties.getLogAgentName();
    Delegate.init(logAgentName);
   
    init(true, Externals.RUNNING_MODE_COMMAND_LINE);
  }

  public void showLicense() throws Exception {
    System.out.println("SuperWatchdog version " + version + " " +
      "Copyright Acelet.org. 1999-2008. All rights reserved");
    System.out.println("GNU GENERAL PUBLIC LICENSE v2");
    try {
      Thread.currentThread().sleep(3000);
    } catch (Exception ex) {
    }
  }

  public void process(String[] args) throws Exception {
    for (int i = 0; i < args.length; i++) {
      if (args[i].equalsIgnoreCase("-" + NO_PERIODIC_PROMPT))
        noPeriodicPrompt = true;
    }

    init();

    while (true) {
      if (noPeriodicPrompt == false)
        iAmAlive();

      try {
        readRefreshTime();
        readFromDatabase();
        readWorkingChores();
        checkDurations();
      } catch (Throwable th) {
        System.err.println("Watchdogging: " + new Date() + ": " + th.toString());
      }
      try {
        Thread.currentThread().sleep(interval);
      } catch (Exception excep) {
        excep.printStackTrace();
      }
    }
  }

  public static void main(String[] args) throws Exception {
    new WatchdoggingDaemon().process(args);
  }
}
TOP

Related Classes of com.acelet.s.watchdog.WatchdoggingDaemon

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.