mirror of
https://github.com/troglobit/finit.git
synced 2026-11-17 19:30:29 +00:00
Remove support for service callback plugins
This patch removes the now heavily outdated (and non-working) support for callback plugins. I.e. plugins that attach themselves to services listed in /etc/finit.conf and can be queried to determine if a service should be started or stopped. The Finit3 support for adding/removing services at runtime with plain text *.conf files in /etc/finit.d and `initctl reload`, this old, and rather cumbersome service callback feature, is not longer supported. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
6b237b7b00
commit
5a3397419f
5 files changed
+8
-63
No files matched your search
+7
-20
@@ -1,10 +1,11 @@
|
|||||||
Hooks, Callbacks & Plugins
|
Hooks & Plugins
|
||||||
==========================
|
===============
|
||||||
|
|
||||||
Finit provides only the bare necessities for starting and supervising
|
Finit can be extended to add general functionality in the form of I/O
|
||||||
processes, with an emphasis on *bare* — for your convenience it does
|
monitors, built-in inetd services, or hook plugins.
|
||||||
however come with support for hooks, service callbacks and plugins that
|
|
||||||
can used to extend finit with.
|
The following sections detail existing plugins and hook points. For
|
||||||
|
more information, see the plugins listed below.
|
||||||
|
|
||||||
|
|
||||||
Plugins
|
Plugins
|
||||||
@@ -124,20 +125,6 @@ they are called I/O plugins and are called from the finit main loop when
|
|||||||
more help and ideas.
|
more help and ideas.
|
||||||
|
|
||||||
|
|
||||||
Callbacks
|
|
||||||
---------
|
|
||||||
|
|
||||||
Callback plugins are called by finit right before a process is started,
|
|
||||||
or restarted if it exits. The callback runs as a separate process and
|
|
||||||
receives a pointer to the `svc_t` of the service, with all command line
|
|
||||||
parameters free to modify as needed.
|
|
||||||
|
|
||||||
All the callback needs to do is respond with one of: `SVC_STOP (0)`
|
|
||||||
tells Finit to *not* start the service, `SVC_START (1)` to start the
|
|
||||||
service, or `SVC_RELOAD (2)` to have finit signal the process with
|
|
||||||
`SIGHUP`.
|
|
||||||
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
-- Local Variables:
|
-- Local Variables:
|
||||||
-- mode: markdown
|
-- mode: markdown
|
||||||
|
|||||||
@@ -109,20 +109,6 @@ int plugin_unregister(plugin_t *plugin)
|
|||||||
#ifndef ENABLE_STATIC
|
#ifndef ENABLE_STATIC
|
||||||
TAILQ_REMOVE(&plugins, plugin, link);
|
TAILQ_REMOVE(&plugins, plugin, link);
|
||||||
|
|
||||||
if (plugin->svc.cb) {
|
|
||||||
svc_t *svc;
|
|
||||||
|
|
||||||
/* Unregister plugin callback for all matching services */
|
|
||||||
for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) {
|
|
||||||
if (strcmp(svc->cmd, plugin->name))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
svc->cb = NULL;
|
|
||||||
svc->dynamic = 0;
|
|
||||||
svc->dynamic_stop = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_d("%s exiting ...", plugin->name);
|
_d("%s exiting ...", plugin->name);
|
||||||
free(plugin->name);
|
free(plugin->name);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -100,13 +100,6 @@ typedef struct plugin {
|
|||||||
* NOTE: Must match cmd for services or inetd plugins! */
|
* NOTE: Must match cmd for services or inetd plugins! */
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
/* Service callback to be called once per lap of runloop. */
|
|
||||||
struct {
|
|
||||||
int dynamic; /* Callback wants external events as well. */
|
|
||||||
int dynamic_stop; /* Callback allows dynamic events to stop. */
|
|
||||||
svc_cmd_t (*cb)(svc_t *svc, int event, void *event_arg);
|
|
||||||
} svc;
|
|
||||||
|
|
||||||
/* List of hook callbacks. */
|
/* List of hook callbacks. */
|
||||||
struct {
|
struct {
|
||||||
void *arg; /* Optional argument to callback func. */
|
void *arg; /* Optional argument to callback func. */
|
||||||
|
|||||||
@@ -608,13 +608,6 @@ recreate:
|
|||||||
while ((cmd = strtok(NULL, " ")))
|
while ((cmd = strtok(NULL, " ")))
|
||||||
strlcpy(svc->args[i++], cmd, sizeof(svc->args[0]));
|
strlcpy(svc->args[i++], cmd, sizeof(svc->args[0]));
|
||||||
svc->args[i][0] = 0;
|
svc->args[i][0] = 0;
|
||||||
|
|
||||||
plugin = plugin_find(svc->cmd);
|
|
||||||
if (plugin && plugin->svc.cb) {
|
|
||||||
svc->cb = plugin->svc.cb;
|
|
||||||
svc->dynamic = plugin->svc.dynamic;
|
|
||||||
svc->dynamic_stop = plugin->svc.dynamic_stop;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
svc->runlevels = conf_parse_runlevels(runlevels);
|
svc->runlevels = conf_parse_runlevels(runlevels);
|
||||||
|
|||||||
@@ -33,11 +33,7 @@
|
|||||||
#include "inetd.h"
|
#include "inetd.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef int svc_cmd_t;
|
||||||
SVC_STOP = 0, /* Disabled */
|
|
||||||
SVC_START, /* Enabled */
|
|
||||||
SVC_RELOAD /* Enabled, needs restart */
|
|
||||||
} svc_cmd_t;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SVC_TYPE_FREE = 0, /* Free to allocate */
|
SVC_TYPE_FREE = 0, /* Free to allocate */
|
||||||
@@ -113,16 +109,6 @@ typedef struct svc {
|
|||||||
char cmd[MAX_ARG_LEN];
|
char cmd[MAX_ARG_LEN];
|
||||||
char args[MAX_NUM_SVC_ARGS][MAX_ARG_LEN];
|
char args[MAX_NUM_SVC_ARGS][MAX_ARG_LEN];
|
||||||
char desc[MAX_STR_LEN];
|
char desc[MAX_STR_LEN];
|
||||||
|
|
||||||
/* For external plugins. If @cb is set, a plugin is loaded.
|
|
||||||
* @dynamic: Set by plugins that want dynamic events.
|
|
||||||
* @dynamic_stop: Set by plugins that allow dyn. events to stop it as well.
|
|
||||||
* @private: Can be used freely by plugin, e.g., to store "states".
|
|
||||||
*/
|
|
||||||
int dynamic;
|
|
||||||
int dynamic_stop;
|
|
||||||
int private;
|
|
||||||
svc_cmd_t (*cb)(struct svc *svc, int event, void *event_arg);
|
|
||||||
} svc_t;
|
} svc_t;
|
||||||
|
|
||||||
typedef struct svc_map svc_map_t;
|
typedef struct svc_map svc_map_t;
|
||||||
|
|||||||
Reference in new issue
Block a user