From b8836f7ececb3c1580396bdf3a6b67d0591c0f39 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sun, 17 May 2020 17:43:01 +0200 Subject: [PATCH] autoreload: Abort if we can't locate the child plugin --- autoreload/autoreload.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/autoreload/autoreload.py b/autoreload/autoreload.py index 5105568..9a12aec 100755 --- a/autoreload/autoreload.py +++ b/autoreload/autoreload.py @@ -1,11 +1,12 @@ #!/usr/bin/env python3 from pyln.client import Plugin import json +import os import psutil import subprocess +import sys import threading import time -import os try: # C-lightning v0.7.2 @@ -233,6 +234,8 @@ def restart(plugin): # any cli options. So we're doomed to get our parent cmdline and parse out the # argument by hand. parent = psutil.Process().parent() +while parent.name() != 'lightningd': + parent = parent.parent() cmdline = parent.cmdline() plugin.path = None @@ -243,7 +246,6 @@ for c in cmdline: plugin.path = c[len(prefix):] break - if plugin.path: plugin.child = ChildPlugin(plugin.path, plugin) @@ -254,6 +256,10 @@ if plugin.path: inject_manifest(plugin, plugin.child.manifest) +else: + plugin.log("Could not locate the plugin to control: {cmdline}".format(cmdline=cmdline)) + sys.exit(1) + # Now we can run the actual plugin plugin.add_option("autoreload-plugin", None, "Path to the plugin that we should be watching and reloading.")