From f556be5d826afa2f60637a9ee0fcad295362791b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 7 Aug 2023 13:35:54 +0930 Subject: [PATCH] renepay: allow it to die gracefully without crashing lightningd. Suggested-by: @Lagrang3 Signed-off-by: Rusty Russell --- lightningd/plugin.c | 3 ++- tests/test_plugin.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 3e7aa88fe..8734dc6da 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -2340,7 +2340,8 @@ void plugins_set_builtin_plugins_dir(struct plugins *plugins, take(path_join(NULL, dir, list_of_builtin_plugins[i])), NULL, - /* important = */ true, + /* important = */ + !streq(list_of_builtin_plugins[i], "cln-renepay"), NULL, NULL); } diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 163444232..c5549edd7 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -4255,3 +4255,21 @@ def test_all_subscription(node_factory, directory): # shutdown and connect are subscribed before the wildcard, so is handled by that handler assert not l2.daemon.is_in_log(f'.*test_libplugin: all: shutdown.*') assert not l2.daemon.is_in_log(f'.*test_libplugin: all: connect.*') + + +def test_renepay_not_important(node_factory): + # I mean, it's *important*, it's just not "mission-critical" just yet! + l1 = node_factory.get_node(options={'allow-deprecated-apis': True}) + + assert not any([p['name'] == 'cln-renepay' for p in l1.rpc.listconfigs()['important-plugins']]) + assert [p['name'] for p in l1.rpc.listconfigs()['plugins'] if p['name'] == 'cln-renepay'] == ['cln-renepay'] + + # We can kill it without cln dying. + line = l1.daemon.is_in_log(r'.*started\([0-9]*\).*plugins/cln-renepay') + pidstr = re.search(r'.*started\(([0-9]*)\).*plugins/cln-renepay', line).group(1) + os.kill(int(pidstr), signal.SIGKILL) + l1.daemon.wait_for_log('plugin-cln-renepay: Killing plugin: exited during normal operation') + + # But we don't shut down, and we can restrart. + assert [p['name'] for p in l1.rpc.listconfigs()['plugins'] if p['name'] == 'cln-renepay'] == [] + l1.rpc.plugin_start(os.path.join(os.getcwd(), 'plugins/cln-renepay'))