From fbf79b148b29ecf99a704947d999190cdbb4e517 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sat, 14 Jan 2023 09:56:18 +0100 Subject: [PATCH] CLI: poor man's detection of already running daemon. --- run_electrum | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/run_electrum b/run_electrum index b6f5d61b1..49e9a0f2a 100755 --- a/run_electrum +++ b/run_electrum @@ -391,6 +391,13 @@ def main(): cmdname = config.get('cmd') 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 + lockfile = daemon.get_lockfile(config) + if os.path.exists(lockfile): + print_stderr("Daemon already running (lockfile detected).") + print_stderr("Run 'electrum stop' to stop the daemon.") + sys.exit(1) # fork before creating the asyncio event loop pid = os.fork() if pid: