Browse Source

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

follow-up fbf79b148b
SomberNight 3 years ago
parent
commit
cb11e1faed
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 7
      run_electrum

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

Loading…
Cancel
Save