shut down trades before main wallet to finish processing
This commit is contained in:
parent
de3317b05d
commit
30e199c56e
@ -346,6 +346,7 @@ public abstract class HavenoExecutable implements GracefulShutDownHandler, Haven
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
injector.getInstance(TradeManager.class).shutDown();
|
||||
injector.getInstance(PriceFeedService.class).shutDown();
|
||||
injector.getInstance(ArbitratorManager.class).shutDown();
|
||||
injector.getInstance(TradeStatisticsManager.class).shutDown();
|
||||
@ -362,11 +363,13 @@ public abstract class HavenoExecutable implements GracefulShutDownHandler, Haven
|
||||
injector.getInstance(P2PService.class).shutDown(() -> {
|
||||
log.info("Done shutting down OpenOfferManager, OfferBookService, and P2PService");
|
||||
|
||||
// shut down connections pool
|
||||
log.info("Shutting down connections");
|
||||
Connection.shutDownExecutor(30);
|
||||
|
||||
// shut down monero wallets and connections
|
||||
injector.getInstance(WalletsSetup.class).shutDownComplete.addListener((ov, o, n) -> {
|
||||
log.info("Shutting down connections");
|
||||
Connection.shutDownExecutor(30);
|
||||
|
||||
|
||||
// done shutting down
|
||||
log.info("Graceful shutdown completed. Exiting now.");
|
||||
module.close(injector);
|
||||
|
@ -27,12 +27,15 @@ import haveno.common.persistence.PersistenceManager;
|
||||
import haveno.common.setup.GracefulShutDownHandler;
|
||||
import haveno.common.util.Profiler;
|
||||
import haveno.core.api.XmrConnectionService;
|
||||
import haveno.core.app.AvoidStandbyModeService;
|
||||
import haveno.core.app.HavenoExecutable;
|
||||
import haveno.core.offer.OfferBookService;
|
||||
import haveno.core.offer.OpenOfferManager;
|
||||
import haveno.core.provider.price.PriceFeedService;
|
||||
import haveno.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
|
||||
import haveno.core.trade.HavenoUtils;
|
||||
import haveno.core.trade.TradeManager;
|
||||
import haveno.core.trade.statistics.TradeStatisticsManager;
|
||||
import haveno.core.xmr.setup.WalletsSetup;
|
||||
import haveno.core.xmr.wallet.BtcWalletService;
|
||||
import haveno.core.xmr.wallet.XmrWalletService;
|
||||
@ -107,7 +110,11 @@ public abstract class ExecutableForAppWithP2p extends HavenoExecutable {
|
||||
}
|
||||
|
||||
JsonFileManager.shutDownAllInstances();
|
||||
injector.getInstance(TradeManager.class).shutDown();
|
||||
injector.getInstance(PriceFeedService.class).shutDown();
|
||||
injector.getInstance(ArbitratorManager.class).shutDown();
|
||||
injector.getInstance(TradeStatisticsManager.class).shutDown();
|
||||
injector.getInstance(AvoidStandbyModeService.class).shutDown();
|
||||
|
||||
// shut down open offer manager
|
||||
log.info("Shutting down OpenOfferManager, OfferBookService, and P2PService");
|
||||
@ -120,12 +127,14 @@ public abstract class ExecutableForAppWithP2p extends HavenoExecutable {
|
||||
injector.getInstance(P2PService.class).shutDown(() -> {
|
||||
log.info("Done shutting down OpenOfferManager, OfferBookService, and P2PService");
|
||||
|
||||
// shut down connections pool
|
||||
log.info("Shutting down connections");
|
||||
Connection.shutDownExecutor(30);
|
||||
|
||||
// shut down monero wallets and connections
|
||||
injector.getInstance(WalletsSetup.class).shutDownComplete.addListener((ov, o, n) -> {
|
||||
module.close(injector);
|
||||
PersistenceManager.flushAllDataToDiskAtShutdown(() -> {
|
||||
log.info("Shutting down connections");
|
||||
Connection.shutDownExecutor(30);
|
||||
|
||||
// done shutting down
|
||||
log.info("Graceful shutdown completed. Exiting now.");
|
||||
|
@ -664,9 +664,11 @@ public class XmrWalletService {
|
||||
|
||||
// remove listeners which stops polling wallet
|
||||
// TODO monero-java: wallet.stopPolling()?
|
||||
if (wallet != null) {
|
||||
for (MoneroWalletListenerI listener : new HashSet<>(wallet.getListeners())) {
|
||||
wallet.removeListener(listener);
|
||||
synchronized (walletLock) {
|
||||
if (wallet != null) {
|
||||
for (MoneroWalletListenerI listener : new HashSet<>(wallet.getListeners())) {
|
||||
wallet.removeListener(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -676,10 +678,7 @@ public class XmrWalletService {
|
||||
|
||||
// shut down trade and main wallets at same time
|
||||
walletListeners.clear();
|
||||
List<Runnable> tasks = new ArrayList<Runnable>();
|
||||
if (tradeManager != null) tasks.add(() -> tradeManager.shutDown());
|
||||
tasks.add(() -> closeMainWallet(true));
|
||||
HavenoUtils.awaitTasks(tasks);
|
||||
closeMainWallet(true);
|
||||
log.info("Done shutting down all wallets");
|
||||
}
|
||||
|
||||
@ -984,13 +983,15 @@ public class XmrWalletService {
|
||||
}
|
||||
|
||||
private void closeMainWallet(boolean save) {
|
||||
try {
|
||||
if (wallet != null) {
|
||||
closeWallet(wallet, true);
|
||||
wallet = null;
|
||||
synchronized (walletLock) {
|
||||
try {
|
||||
if (wallet != null) {
|
||||
closeWallet(wallet, true);
|
||||
wallet = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("Error closing main monero-wallet-rpc subprocess: " + e.getMessage() + ". Was Haveno stopped manually with ctrl+c?");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("Error closing main monero-wallet-rpc subprocess: " + e.getMessage() + ". Was Haveno stopped manually with ctrl+c?");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user