Changeset 9b8d3eb


Ignore:
Timestamp:
Nov 22, 2013 5:27:49 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
9e4d5c0e
Parents:
dbe0a82
Message:

Startup:

Wait a while and recheck if a recent ping file is there,
so that a crashed router doesn't prevent a restart (ticket #633)

File:
1 edited

Legend:

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

    rdbe0a82 r9b8d3eb  
    235235        // Check for other router but do not start a thread yet so the update doesn't cause
    236236        // a NCDFE
    237         if (!isOnlyRouterRunning()) {
    238             _eventLog.addEvent(EventLog.ABORTED, "Another router running");
    239             System.err.println("ERROR: There appears to be another router already running!");
    240             System.err.println("       Please make sure to shut down old instances before starting up");
    241             System.err.println("       a new one.  If you are positive that no other instance is running,");
    242             System.err.println("       please delete the file " + getPingFile().getAbsolutePath());
    243             System.exit(-1);
     237        for (int i = 0; i < 14; i++) {
     238            // Wrapper can start us up too quickly after a crash, the ping file
     239            // may still be less than LIVELINESS_DELAY (60s) old.
     240            // So wait at least 60s to be sure.
     241            if (isOnlyRouterRunning()) {
     242                if (i > 0)
     243                    System.err.println("INFO: No, there wasn't another router already running. Proceeding with startup.");
     244                break;
     245            }
     246            if (i < 13) {
     247                if (i == 0)
     248                    System.err.println("WARN: There may be another router already running. Waiting a while to be sure...");
     249                // yes this is ugly to sleep in the constructor.
     250                try { Thread.sleep(5000); } catch (InterruptedException ie) {}
     251            } else {
     252                _eventLog.addEvent(EventLog.ABORTED, "Another router running");
     253                System.err.println("ERROR: There appears to be another router already running!");
     254                System.err.println("       Please make sure to shut down old instances before starting up");
     255                System.err.println("       a new one.  If you are positive that no other instance is running,");
     256                System.err.println("       please delete the file " + getPingFile().getAbsolutePath());
     257                System.exit(-1);
     258            }
    244259        }
    245260
Note: See TracChangeset for help on using the changeset viewer.