#if defined(WITH_SUPERVISION)
#define _GNU_SOURCE
-#define AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO
#include <string.h>
#include <errno.h>
#include "wrap-json.h"
#include "jobs.h"
-extern struct afb_config *main_config;
-
/* api and apiset name */
static const char supervision_apiname[] = AFS_SUPERVISION_APINAME;
static const char supervisor_apiname[] = AFS_SUPERVISOR_APINAME;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
/* the standard apiset */
-extern struct afb_apiset *main_apiset;
+static struct {
+ struct afb_apiset *apiset;
+ struct json_object *config;
+} global;
/* the supervision apiset (not exported) */
static struct afb_apiset *supervision_apiset;
ERROR("Creation of supervisor failed: %m");
goto end;
}
- afb_stub_ws_on_hangup(supervisor, on_supervisor_hangup);
+ afb_stub_ws_set_on_hangup(supervisor, on_supervisor_hangup);
/* successful termination */
goto end;
/**
* initialize the supervision
*/
-int afb_supervision_init()
+int afb_supervision_init(struct afb_apiset *apiset, struct json_object *config)
{
int rc;
struct sigaction sa;
return rc;
}
+ /* init the globals */
+ global.apiset = apiset;
+ global.config = config;
+
/* get SIGHUP */
memset(&sa, 0, sizeof sa);
sa.sa_handler = on_sighup;
afb_xreq_reply(xreq, list, NULL, NULL);
break;
case Config:
- afb_xreq_reply(xreq, afb_config_json(main_config), NULL, NULL);
+ afb_xreq_reply(xreq, json_object_get(global.config), NULL, NULL);
break;
case Trace:
if (!trace)
if (wrap_json_unpack(args, "{ss ss s?o*}", "api", &api, "verb", &verb, "args", &sub))
afb_xreq_reply(xreq, NULL, "error", "bad request");
else {
- xapi = afb_apiset_lookup_started(main_apiset, api, 1);
+ xapi = afb_apiset_lookup_started(global.apiset, api, 1);
if (!xapi)
afb_xreq_reply_unknown_api(xreq);
else {