diff options
-rw-r--r-- | src/afs-config.c | 9 | ||||
-rw-r--r-- | src/afs-config.h | 1 | ||||
-rw-r--r-- | src/afs-main.c | 10 |
3 files changed, 19 insertions, 1 deletions
diff --git a/src/afs-config.c b/src/afs-config.c index eee4ccc0..71d5ab74 100644 --- a/src/afs-config.c +++ b/src/afs-config.c @@ -71,6 +71,7 @@ #define SET_NAME 'n' #define SET_TCP_PORT 'p' #define SET_QUIET 'q' +#define WS_SERVICE 's' #define SET_AUTH_TOKEN 't' #define SET_UPLOAD_DIR 'u' #define DISPLAY_VERSION 'V' @@ -78,7 +79,7 @@ #define SET_WORK_DIR 'w' const char shortopts[] = - "hn:p:qrt:u:Vvw:" + "hn:p:qrs:t:u:Vvw:" ; // Command line structure hold cli --command + help text @@ -113,6 +114,7 @@ static AFB_options cliOptions[] = { {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"}, @@ -324,6 +326,10 @@ static void parse_arguments(int argc, char **argv, struct afs_config *config) config->name = argvalstr(optc); break; + case WS_SERVICE: + config->ws_server = argvalstr(optc); + break; + case DISPLAY_VERSION: noarg(optc); printVersion(stdout); @@ -401,6 +407,7 @@ void afs_config_dump(struct afs_config *config) S(uploaddir) S(token) S(name) + S(ws_server) D(httpdPort) D(cacheTimeout) diff --git a/src/afs-config.h b/src/afs-config.h index ca7dfc24..f374e81d 100644 --- a/src/afs-config.h +++ b/src/afs-config.h @@ -26,6 +26,7 @@ struct afs_config { 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; diff --git a/src/afs-main.c b/src/afs-main.c index 980a1bce..93e49323 100644 --- a/src/afs-main.c +++ b/src/afs-main.c @@ -30,6 +30,7 @@ #include "afb-hswitch.h" #include "afb-hreq.h" #include "afb-apiset.h" +#include "afb-api-ws.h" #include "afb-session.h" #include "afs-supervisor.h" @@ -149,6 +150,15 @@ static void start(int signum, void *arg) goto error; } + /* 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; |