forked from I2P_Developers/i2p.i2p
Router: Fix wrapper.config path in OOM message when installed as
Debian package, but not running as a service (ticket #2223)
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
2018-05-26 zzz
|
||||||
|
* Router: Fix wrapper.config path in OOM message when installed as
|
||||||
|
Debian package, but not running as a service (ticket #2223)
|
||||||
|
|
||||||
2018-05-25 zzz
|
2018-05-25 zzz
|
||||||
* Console: Fix changes to wrong tunnel on /configtunnels (ticket #2227)
|
* Console: Fix changes to wrong tunnel on /configtunnels (ticket #2227)
|
||||||
* i2ptunnel: Fix dup tunnels clicking generate on new tunnel (ticket #2225)
|
* i2ptunnel: Fix dup tunnels clicking generate on new tunnel (ticket #2225)
|
||||||
|
@ -49,26 +49,16 @@ public class OOMListener implements I2PThread.OOMEventListener {
|
|||||||
log.log(Log.CRIT, "Thread ran out of memory, shutting down I2P", oom);
|
log.log(Log.CRIT, "Thread ran out of memory, shutting down I2P", oom);
|
||||||
log.log(Log.CRIT, "free mem: " + Runtime.getRuntime().freeMemory() +
|
log.log(Log.CRIT, "free mem: " + Runtime.getRuntime().freeMemory() +
|
||||||
" total mem: " + Runtime.getRuntime().totalMemory());
|
" total mem: " + Runtime.getRuntime().totalMemory());
|
||||||
// Can't find any System property or wrapper property that gives
|
String path = getWrapperConfigPath(_context);
|
||||||
// you the actual config file path, have to guess
|
|
||||||
String path;
|
|
||||||
if (SystemVersion.isLinuxService()) {
|
|
||||||
if (SystemVersion.isGentoo())
|
|
||||||
path = "/usr/share/i2p";
|
|
||||||
else
|
|
||||||
path = "/etc/i2p";
|
|
||||||
} else {
|
|
||||||
path = _context.getBaseDir().toString();
|
|
||||||
}
|
|
||||||
if (_context.hasWrapper()) {
|
if (_context.hasWrapper()) {
|
||||||
log.log(Log.CRIT, "To prevent future shutdowns, increase wrapper.java.maxmemory in " +
|
log.log(Log.CRIT, "To prevent future shutdowns, increase wrapper.java.maxmemory in " +
|
||||||
path + File.separatorChar + "wrapper.config");
|
path);
|
||||||
} else if (!SystemVersion.isWindows()) {
|
} else if (!SystemVersion.isWindows()) {
|
||||||
log.log(Log.CRIT, "To prevent future shutdowns, increase MAXMEMOPT in " +
|
log.log(Log.CRIT, "To prevent future shutdowns, increase MAXMEMOPT in " +
|
||||||
path + File.separatorChar + "runplain.sh or /usr/bin/i2prouter-nowrapper");
|
_context.getBaseDir() + File.separatorChar + "runplain.sh or /usr/bin/i2prouter-nowrapper");
|
||||||
} else {
|
} else {
|
||||||
log.log(Log.CRIT, "To prevent future shutdowns, run the restartable version of I2P, and increase wrapper.java.maxmemory in " +
|
log.log(Log.CRIT, "To prevent future shutdowns, run the restartable version of I2P, and increase wrapper.java.maxmemory in " +
|
||||||
path + File.separatorChar + "wrapper.config");
|
path);
|
||||||
}
|
}
|
||||||
} catch (OutOfMemoryError oome) {}
|
} catch (OutOfMemoryError oome) {}
|
||||||
try {
|
try {
|
||||||
@ -81,4 +71,41 @@ public class OOMListener implements I2PThread.OOMEventListener {
|
|||||||
_context.router().shutdown(Router.EXIT_OOM);
|
_context.router().shutdown(Router.EXIT_OOM);
|
||||||
} catch (OutOfMemoryError oome) {}
|
} catch (OutOfMemoryError oome) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Best guess if running from a Debian package
|
||||||
|
* @since 0.9.35
|
||||||
|
*/
|
||||||
|
private static boolean isDebianPackage(RouterContext ctx) {
|
||||||
|
boolean isDebian = !SystemVersion.isWindows() && !SystemVersion.isMac() &&
|
||||||
|
!SystemVersion.isGentoo() && !SystemVersion.isAndroid() &&
|
||||||
|
System.getProperty("os.name").startsWith("Linux") &&
|
||||||
|
(new File("/etc/debian_version")).exists();
|
||||||
|
return isDebian &&
|
||||||
|
ctx.getBaseDir().getPath().equals("/usr/share/i2p") &&
|
||||||
|
ctx.getBooleanProperty("router.updateDisabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Best guess of wrapper.config path.
|
||||||
|
* Can't find any System property or wrapper property that gives
|
||||||
|
* you the actual config file path, have to guess.
|
||||||
|
* Does not necessarily exist.
|
||||||
|
* @since 0.9.35 consolidated from above and BloomFilterIVValidator
|
||||||
|
*/
|
||||||
|
public static String getWrapperConfigPath(RouterContext ctx) {
|
||||||
|
File path;
|
||||||
|
if (SystemVersion.isLinuxService()) {
|
||||||
|
if (SystemVersion.isGentoo())
|
||||||
|
path = new File("/usr/share/i2p");
|
||||||
|
else
|
||||||
|
path = new File("/etc/i2p");
|
||||||
|
} else if (isDebianPackage(ctx)) {
|
||||||
|
path = new File("/etc/i2p");
|
||||||
|
} else {
|
||||||
|
path = ctx.getBaseDir();
|
||||||
|
}
|
||||||
|
path = new File(path, "wrapper.config");
|
||||||
|
return path.getPath();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||||||
|
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.router.RouterContext;
|
import net.i2p.router.RouterContext;
|
||||||
|
import net.i2p.router.tasks.OOMListener;
|
||||||
import net.i2p.router.util.DecayingBloomFilter;
|
import net.i2p.router.util.DecayingBloomFilter;
|
||||||
import net.i2p.router.util.DecayingHashSet;
|
import net.i2p.router.util.DecayingHashSet;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
@ -102,27 +103,20 @@ class BloomFilterIVValidator implements IVValidator {
|
|||||||
private void warn(long maxMemory, int KBps, long recMaxMem, int threshKBps) {
|
private void warn(long maxMemory, int KBps, long recMaxMem, int threshKBps) {
|
||||||
if (SystemVersion.isAndroid())
|
if (SystemVersion.isAndroid())
|
||||||
return;
|
return;
|
||||||
// Can't find any System property or wrapper property that gives
|
String path = OOMListener.getWrapperConfigPath(_context);
|
||||||
// you the actual config file path, have to guess
|
|
||||||
String path;
|
|
||||||
if (SystemVersion.isLinuxService()) {
|
|
||||||
path = "/etc/i2p";
|
|
||||||
} else {
|
|
||||||
path = _context.getBaseDir().toString();
|
|
||||||
}
|
|
||||||
String msg =
|
String msg =
|
||||||
"Configured for " + DataHelper.formatSize(KBps *1024L) +
|
"Configured for " + DataHelper.formatSize(KBps *1024L) +
|
||||||
"Bps share bandwidth but only " +
|
"Bps share bandwidth but only " +
|
||||||
DataHelper.formatSize(maxMemory) + "B available memory.";
|
DataHelper.formatSize(maxMemory) + "B available memory.";
|
||||||
if (_context.hasWrapper()) {
|
if (_context.hasWrapper()) {
|
||||||
msg += " Recommend increasing wrapper.java.maxmemory in " +
|
msg += " Recommend increasing wrapper.java.maxmemory in " +
|
||||||
path + File.separatorChar + "wrapper.config";
|
path;
|
||||||
} else if (!SystemVersion.isWindows()) {
|
} else if (!SystemVersion.isWindows()) {
|
||||||
msg += " Recommend increasing MAXMEMOPT in " +
|
msg += " Recommend increasing MAXMEMOPT in " +
|
||||||
path + File.separatorChar + "runplain.sh or /usr/bin/i2prouter-nowrapper";
|
_context.getBaseDir() + File.separatorChar + "runplain.sh or /usr/bin/i2prouter-nowrapper";
|
||||||
} else {
|
} else {
|
||||||
msg += " Recommend running the restartable version of I2P, and increasing wrapper.java.maxmemory in " +
|
msg += " Recommend running the restartable version of I2P, and increasing wrapper.java.maxmemory in " +
|
||||||
path + File.separatorChar + "wrapper.config";
|
path;
|
||||||
}
|
}
|
||||||
// getMaxMemory() returns significantly lower than wrapper config, so add 10%
|
// getMaxMemory() returns significantly lower than wrapper config, so add 10%
|
||||||
msg += " to at least " + (recMaxMem * 11 / 10 / (1024*1024)) + " (MB)" +
|
msg += " to at least " + (recMaxMem * 11 / 10 / (1024*1024)) + " (MB)" +
|
||||||
|
Reference in New Issue
Block a user