Changeset 4ab46b1


Ignore:
Timestamp:
May 21, 2009 3:40:33 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
aa04820, e0652a46
Parents:
79954ce
Message:
  • Watchdog:
    • Log memory stats
    • Dump threads on linux
    • Restart after 20 minutes (give the dog his teeth back)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/RouterWatchdog.java

    r79954ce r4ab46b1  
    44import net.i2p.stat.Rate;
    55import net.i2p.stat.RateStat;
     6import net.i2p.util.ShellCommand;
    67import net.i2p.util.Log;
    78
     
    1415    private Log _log;
    1516    private RouterContext _context;
     17    private int _consecutiveErrors;
    1618   
    1719    private static final long MAX_JOB_RUN_LAG = 60*1000;
     
    4850   
    4951    private boolean shutdownOnHang() {
     52        // Client manager starts complaining after 10 minutes, and we run every minute,
     53        // so this will restart 20 minutes after we lose a lease, if the wrapper is present.
     54        if (_consecutiveErrors >= 10 && System.getProperty("wrapper.version") != null)
     55            return true;
    5056        return Boolean.valueOf(_context.getProperty("watchdog.haltOnHang", "false")).booleanValue();
    5157    }
     
    8187            double kbps = (r != null ? r.getAverageValue() : 0);
    8288            _log.error("Outbound send rate: " + kbps + "KBps");
     89            long max = Runtime.getRuntime().maxMemory();
     90            long used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
     91            _log.error("Memory: " + DataHelper.formatSize(used) + '/' + DataHelper.formatSize(max));
     92            if (_consecutiveErrors == 1) {
     93                // This might work on linux...
     94                // It won't on windows, and we can't call i2prouter.bat either, it does something
     95                // completely different...
     96                ShellCommand sc = new ShellCommand();
     97                boolean success = sc.executeSilentAndWaitTimed("./i2prouter dump", 10);
     98                if (success)
     99                    _log.error("DUMPED THREADS TO WRAPPER LOG");
     100            }
    83101        }
    84102    }
     
    104122        ok = ok && (verifyClientLiveliness() || netErrors >= 5);
    105123       
    106         if (!ok) {
     124        if (ok) {
     125            _consecutiveErrors = 0;
     126        } else {
     127            _consecutiveErrors++;
    107128            dumpStatus();
    108129            if (shutdownOnHang()) {
Note: See TracChangeset for help on using the changeset viewer.