lightningd/plugin.c: Add important plugins, which if they terminate, lightningd also terminates.

Changelog-Added: New option `--important-plugin` loads a plugin is so important that if it dies, `lightningd` will exit rather than continue.  You can still `--disable-plugin` it, however, which trumps `--important-plugin` and it will not be started at all.
This commit is contained in:
ZmnSCPxj jxPCSnmZ
2020-07-29 19:24:07 +08:00
committed by neil saitug
parent 50600dce95
commit a847487bbe
7 changed files with 123 additions and 24 deletions

View File

@@ -79,6 +79,10 @@ struct plugin {
/* An array of currently pending RPC method calls, to be killed if the
* plugin exits. */
struct list_head pending_rpccalls;
/* If set, the plugin is so important that if it terminates early,
* C-lightning should terminate as well. */
bool important;
};
/**
@@ -103,6 +107,9 @@ struct plugins {
/* Blacklist of plugins from --disable-plugin */
const char **blacklist;
/* Whether we are shutting down (`plugins_free` is called) */
bool shutdown;
};
/* The value of a plugin option, which can have different types.
@@ -175,13 +182,15 @@ void plugins_free(struct plugins *plugins);
* @param plugins: Plugin context
* @param path: The path of the executable for this plugin
* @param start_cmd: The optional JSON command which caused this.
* @param important: The plugin is important.
*
* If @start_cmd, then plugin_cmd_killed or plugin_cmd_succeeded will be called
* on it eventually.
*/
struct plugin *plugin_register(struct plugins *plugins,
const char* path TAKES,
struct command *start_cmd);
struct command *start_cmd,
bool important);
/**
* Returns true if the provided name matches a plugin command