From cb11e1faed11fb966026ace287103980f3397630 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 25 Jan 2023 15:35:42 +0000 Subject: [PATCH] CLI: make "electrum stop" robust to dead daemon / lingering lockfile follow-up fbf79b148b29ecf99a704947d999190cdbb4e517 --- run_electrum | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/run_electrum b/run_electrum index 49e9a0f2a..fb27bf45a 100755 --- a/run_electrum +++ b/run_electrum @@ -392,7 +392,7 @@ def main(): if cmdname == 'daemon' and config.get("detach"): # detect lockfile. - # This is not as goog as get_file_descriptor, but that would require the asyncio loop + # This is not as good as get_file_descriptor, but that would require the asyncio loop lockfile = daemon.get_lockfile(config) if os.path.exists(lockfile): print_stderr("Daemon already running (lockfile detected).") @@ -474,6 +474,11 @@ def handle_cmd(*, cmdname: str, config: 'SimpleConfig', config_options: dict): print_msg("Daemon not running; try 'electrum daemon -d'") if not cmd.requires_network: print_msg("To run this command without a daemon, use --offline") + if cmd.name == "stop": # remove lockfile if it exists, as daemon looks dead + lockfile = daemon.get_lockfile(config) + if os.path.exists(lockfile): + print_msg("Found lingering lockfile for daemon. Removing.") + daemon.remove_lockfile(lockfile) sys_exit(1) except Exception as e: print_stderr(str(e) or repr(e))