improve error logging on shut down
This commit is contained in:
parent
473100620e
commit
74b2db7524
@ -1851,7 +1851,7 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (!isShutDown && getWallet() != null && isWalletConnected()) {
|
if (!isShutDownStarted && getWallet() != null && isWalletConnected()) {
|
||||||
log.warn("Error polling trade wallet for {} {}: {}. Monerod={}", getClass().getSimpleName(), getId(), e.getMessage(), getXmrWalletService().getConnectionsService().getConnection());
|
log.warn("Error polling trade wallet for {} {}: {}. Monerod={}", getClass().getSimpleName(), getId(), e.getMessage(), getXmrWalletService().getConnectionsService().getConnection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,6 +114,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
public class TradeManager implements PersistedDataHost, DecryptedDirectMessageListener {
|
public class TradeManager implements PersistedDataHost, DecryptedDirectMessageListener {
|
||||||
private static final Logger log = LoggerFactory.getLogger(TradeManager.class);
|
private static final Logger log = LoggerFactory.getLogger(TradeManager.class);
|
||||||
|
|
||||||
|
private boolean isShutDownStarted;
|
||||||
private boolean isShutDown;
|
private boolean isShutDown;
|
||||||
private final User user;
|
private final User user;
|
||||||
@Getter
|
@Getter
|
||||||
@ -202,6 +203,8 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||||||
p2PService.addDecryptedDirectMessageListener(this);
|
p2PService.addDecryptedDirectMessageListener(this);
|
||||||
|
|
||||||
failedTradesManager.setUnFailTradeCallback(this::unFailTrade);
|
failedTradesManager.setUnFailTradeCallback(this::unFailTrade);
|
||||||
|
|
||||||
|
xmrWalletService.setTradeManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -293,6 +296,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||||||
|
|
||||||
public void onShutDownStarted() {
|
public void onShutDownStarted() {
|
||||||
log.info("{}.onShutDownStarted()", getClass().getSimpleName());
|
log.info("{}.onShutDownStarted()", getClass().getSimpleName());
|
||||||
|
isShutDownStarted = true;
|
||||||
|
|
||||||
// collect trades to prepare
|
// collect trades to prepare
|
||||||
List<Trade> trades = getAllTrades();
|
List<Trade> trades = getAllTrades();
|
||||||
@ -428,15 +432,17 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||||||
tradesToMaybeRemoveOnError.add(trade);
|
tradesToMaybeRemoveOnError.add(trade);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
if (!isShutDownStarted) {
|
||||||
log.warn("Error initializing {} {}: {}", trade.getClass().getSimpleName(), trade.getId(), e.getMessage());
|
e.printStackTrace();
|
||||||
trade.setInitError(e);
|
log.warn("Error initializing {} {}: {}", trade.getClass().getSimpleName(), trade.getId(), e.getMessage());
|
||||||
|
trade.setInitError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
HavenoUtils.executeTasks(tasks, threadPoolSize);
|
HavenoUtils.executeTasks(tasks, threadPoolSize);
|
||||||
log.info("Done initializing persisted trades");
|
log.info("Done initializing persisted trades");
|
||||||
if (isShutDown) return;
|
if (isShutDownStarted) return;
|
||||||
|
|
||||||
// remove skipped trades
|
// remove skipped trades
|
||||||
trades.removeAll(tradesToSkip);
|
trades.removeAll(tradesToSkip);
|
||||||
@ -446,8 +452,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||||||
if (trade.isIdling()) HavenoUtils.submitTask(() -> trade.syncWallet());
|
if (trade.isIdling()) HavenoUtils.submitTask(() -> trade.syncWallet());
|
||||||
}
|
}
|
||||||
|
|
||||||
xmrWalletService.setTradeManager(this);
|
|
||||||
|
|
||||||
// process after all wallets initialized
|
// process after all wallets initialized
|
||||||
if (HavenoUtils.havenoSetup != null) { // null for seednode
|
if (HavenoUtils.havenoSetup != null) { // null for seednode
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user