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