1
0

CLI: make "electrum stop" robust to dead daemon / lingering lockfile

follow-up fbf79b148b
This commit is contained in:
SomberNight
2023-01-25 15:35:42 +00:00
parent 599ac065fb
commit cb11e1faed

View File

@@ -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))