Skip to content

Commit

Permalink
CLI: make "electrum stop" robust to dead daemon / lingering lockfile
Browse files Browse the repository at this point in the history
follow-up fbf79b1
  • Loading branch information
SomberNight committed Jan 25, 2023
1 parent fbbd073 commit e854d23
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion run_electrum
Original file line number Diff line number Diff line change
Expand Up @@ -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).")
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit e854d23

Please sign in to comment.