i2psnark standalone: Add more CLI messages

Increase memory
This commit is contained in:
zzz
2022-03-04 07:15:16 -05:00
parent a7115263f0
commit 22512d3889
3 changed files with 45 additions and 12 deletions

View File

@@ -1259,6 +1259,8 @@ public class Snark
*/
private void fatalRouter(String s, Throwable t) throws RouterException {
_log.error(s, t);
if (!_util.getContext().isRouterContext())
System.out.println(s);
stopTorrent(true);
if (completeListener != null)
completeListener.fatal(this, s);

View File

@@ -1718,21 +1718,31 @@ public class SnarkManager implements CompleteListener, ClientApp, DisconnectList
String link = linkify(torrent);
if (!dontAutoStart && shouldAutoStart() && running) {
if (!_util.connected()) {
addMessage(_t("Connecting to I2P"));
String msg = _t("Connecting to I2P");
addMessage(msg);
if (!_context.isRouterContext())
System.out.println(msg);
boolean ok = _util.connect();
if (!ok) {
if (_context.isRouterContext())
if (_context.isRouterContext()) {
addMessage(_t("Unable to connect to I2P"));
else
addMessage(_t("Error connecting to I2P - check your I2CP settings!") + ' ' + _util.getI2CPHost() + ':' + _util.getI2CPPort());
} else {
msg = _t("Error connecting to I2P - check your I2CP settings!") + ' ' + _util.getI2CPHost() + ':' + _util.getI2CPPort();
addMessage(msg);
System.out.println(msg);
}
// this would rename the torrent to .BAD
//return false;
}
}
torrent.startTorrent();
addMessageNoEscape(_t("Torrent added and started: {0}", link));
if (!_context.isRouterContext())
System.out.println(_t("Torrent added and started: {0}", torrent.getBaseName()));
} else {
addMessageNoEscape(_t("Torrent added: {0}", link));
if (!_context.isRouterContext())
System.out.println(_t("Torrent added: {0}", torrent.getBaseName()));
}
return true;
}
@@ -2554,6 +2564,9 @@ public class SnarkManager implements CompleteListener, ClientApp, DisconnectList
// Test if the router is there
// For standalone, this will probe the router every 60 seconds if not connected
boolean oldOK = routerOK;
// standalone, first time only
if (doMagnets && !_context.isRouterContext())
System.out.println(_t("Connecting to I2P") + ' ' + _util.getI2CPHost() + ':' + _util.getI2CPPort());
routerOK = getBWLimit();
if (routerOK) {
autostart = shouldAutoStart();
@@ -2564,17 +2577,29 @@ public class SnarkManager implements CompleteListener, ClientApp, DisconnectList
String prop = config.getProperty(PROP_META_RUNNING);
if (prop == null || Boolean.parseBoolean(prop)) {
if (!_util.connected()) {
addMessage(_t("Connecting to I2P"));
String msg = _t("Connecting to I2P");
addMessage(msg);
if (!_context.isRouterContext())
System.out.println(msg + ' ' + _util.getI2CPHost() + ':' + _util.getI2CPPort());
// getBWLimit() was successful so this should work
boolean ok = _util.connect();
if (!ok) {
if (_context.isRouterContext())
if (_context.isRouterContext()) {
addMessage(_t("Unable to connect to I2P"));
else
addMessage(_t("Error connecting to I2P - check your I2CP settings!") + ' ' + _util.getI2CPHost() + ':' + _util.getI2CPPort());
} else {
msg = _t("Error connecting to I2P - check your I2CP settings!") + ' ' + _util.getI2CPHost() + ':' + _util.getI2CPPort();
addMessage(msg);
System.out.println(msg);
}
routerOK = false;
autostart = false;
break;
} else {
if (!_context.isRouterContext()) {
msg = "Connected to I2P at " + ' ' + _util.getI2CPHost() + ':' + _util.getI2CPPort();
addMessage(msg);
System.out.println(msg);
}
}
}
addMessageNoEscape(_t("Starting up torrent {0}", linkify(snark)));
@@ -2623,10 +2648,13 @@ public class SnarkManager implements CompleteListener, ClientApp, DisconnectList
if (ok)
cleanupTorrentStatus();
if (!routerOK) {
if (_context.isRouterContext())
if (_context.isRouterContext()) {
addMessage(_t("Unable to connect to I2P"));
else
addMessage(_t("Error connecting to I2P - check your I2CP settings!") + ' ' + _util.getI2CPHost() + ':' + _util.getI2CPPort());
} else {
String msg = _t("Error connecting to I2P - check your I2CP settings!") + ' ' + _util.getI2CPHost() + ':' + _util.getI2CPPort();
addMessage(msg);
System.out.println(msg);
}
}
}
try { Thread.sleep(60*1000); } catch (InterruptedException ie) {}

View File

@@ -8,6 +8,9 @@
# Raise the soft open files soft ulimit to this value, if able
OPEN_FILES_ULIMIT=2048
# Increase memory to 512 MB
JAVA_OPTS='-Xmx512m'
raiseopenfilesulimit() {
OPEN_FILES_SOFT=`ulimit -S -n` 2> /dev/null || return
if [ "$OPEN_FILES_SOFT" != "unlimited" ]
@@ -33,4 +36,4 @@ raiseopenfilesulimit() {
raiseopenfilesulimit
I2P="."
java -jar "$I2P/i2psnark.jar"
java $JAVA_OPTS -jar "$I2P/i2psnark.jar"