Browse Source

mmgen-xmrwallet: force-kill wallet daemon on double Ctrl-C

The MMGen Project 1 year ago
parent
commit
6620db4158
4 changed files with 11 additions and 6 deletions
  1. 2 0
      mmgen/daemon.py
  2. 2 5
      mmgen/main_xmrwallet.py
  3. 1 0
      mmgen/proto/xmr/daemon.py
  4. 6 1
      mmgen/xmrwallet.py

+ 2 - 0
mmgen/daemon.py

@@ -194,6 +194,8 @@ class Daemon(Lockable):
 		if self.state == 'ready':
 			if not silent:
 				msg(f'Stopping {self.desc} on port {self.bind_port}')
+			if self.force_kill:
+				run(['sync'])
 			ret = self.run_cmd(self.stop_cmd,silent=True)
 
 			if self.pids:

+ 2 - 5
mmgen/main_xmrwallet.py

@@ -163,8 +163,5 @@ if cfg.autosign and not cfg.test_suite:
 
 m = op_cls(cfg, xmrwallet_uargs(infile, wallets, spec))
 
-try:
-	if async_run(m.main()):
-		m.post_main()
-except KeyboardInterrupt:
-	ymsg('\nUser interrupt')
+if async_run(m.main()):
+	m.post_main()

+ 1 - 0
mmgen/proto/xmr/daemon.py

@@ -88,6 +88,7 @@ class MoneroWalletDaemon(RPCDaemon):
 	new_console_mswin = True
 	networks = ('mainnet','testnet')
 	rpc_ports = _nw(13131, 13141, None) # testnet is non-standard
+	_reset_ok = ('debug','wait','pids','force_kill')
 
 	def __init__(
 			self,

+ 6 - 1
mmgen/xmrwallet.py

@@ -867,7 +867,12 @@ class MoneroWalletOps:
 
 		async def stop_wallet_daemon(self):
 			if not self.cfg.no_stop_wallet_daemon:
-				await self.c.stop_daemon()
+				try:
+					await self.c.stop_daemon()
+				except KeyboardInterrupt:
+					ymsg('\nForce killing wallet daemon')
+					self.c.daemon.force_kill = True
+					self.c.daemon.stop()
 
 		def get_wallet_fn(self,data,watch_only=None):
 			if watch_only is None: