This allow exportation of the API of the supervisor.
Change-Id: I167ec94f00f40f8c3640377a46820e6a060b24f1
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
#define SET_NAME 'n'
#define SET_TCP_PORT 'p'
#define SET_QUIET 'q'
#define SET_NAME 'n'
#define SET_TCP_PORT 'p'
#define SET_QUIET 'q'
#define SET_AUTH_TOKEN 't'
#define SET_UPLOAD_DIR 'u'
#define DISPLAY_VERSION 'V'
#define SET_AUTH_TOKEN 't'
#define SET_UPLOAD_DIR 'u'
#define DISPLAY_VERSION 'V'
#define SET_WORK_DIR 'w'
const char shortopts[] =
#define SET_WORK_DIR 'w'
const char shortopts[] =
;
// Command line structure hold cli --command + help text
;
// Command line structure hold cli --command + help text
{SET_AUTH_TOKEN, 1, "token", "Initial Secret [default=" AFS_SUPERVISOR_TOKEN ", use --token="" to allow any token]"},
{SET_AUTH_TOKEN, 1, "token", "Initial Secret [default=" AFS_SUPERVISOR_TOKEN ", use --token="" to allow any token]"},
+ {WS_SERVICE, 1, "ws-server", "Povide supervisor as websocket"},
{DISPLAY_VERSION, 0, "version", "Display version and copyright"},
{DISPLAY_HELP, 0, "help", "Display this help"},
{DISPLAY_VERSION, 0, "version", "Display version and copyright"},
{DISPLAY_HELP, 0, "help", "Display this help"},
config->name = argvalstr(optc);
break;
config->name = argvalstr(optc);
break;
+ case WS_SERVICE:
+ config->ws_server = argvalstr(optc);
+ break;
+
case DISPLAY_VERSION:
noarg(optc);
printVersion(stdout);
case DISPLAY_VERSION:
noarg(optc);
printVersion(stdout);
S(uploaddir)
S(token)
S(name)
S(uploaddir)
S(token)
S(name)
D(httpdPort)
D(cacheTimeout)
D(httpdPort)
D(cacheTimeout)
char *uploaddir; // where to store transient files
char *token; // initial authentication token [default NULL no session]
char *name; /* name to set to the daemon */
char *uploaddir; // where to store transient files
char *token; // initial authentication token [default NULL no session]
char *name; /* name to set to the daemon */
+ char *ws_server; /* exported api */
/* integers */
int httpdPort;
/* integers */
int httpdPort;
#include "afb-hswitch.h"
#include "afb-hreq.h"
#include "afb-apiset.h"
#include "afb-hswitch.h"
#include "afb-hreq.h"
#include "afb-apiset.h"
#include "afb-session.h"
#include "afs-supervisor.h"
#include "afb-session.h"
#include "afs-supervisor.h"
+ /* export the service if required */
+ if (main_config->ws_server) {
+ rc = afb_api_ws_add_server(main_config->ws_server, main_apiset);
+ if (rc < 0) {
+ ERROR("Can't export (ws-server) api %s: %m", main_config->ws_server);
+ goto error;
+ }
+ }
+
/* start the services */
if (afb_apiset_start_all_services(main_apiset, 1) < 0)
goto error;
/* start the services */
if (afb_apiset_start_all_services(main_apiset, 1) < 0)
goto error;