#include "afb-plugin.h"
#include "local-def.h"
-#include "afb-apis.h"
+#include "afb-hswitch.h"
+#include "afb-api-so.h"
#include "afb-hsrv.h"
#include "afb-hreq.h"
#include "session.h"
if (pid != 0) _exit (0);
// son process get all data in standalone mode
- printf ("\nAFB: background mode [pid:%d console:%s]\n", getpid(),session->config->console);
+ fprintf (stderr, "\nAFB: background mode [pid:%d console:%s]\n", getpid(),session->config->console);
// redirect default I/O on console
close (2); dup(consoleFD); // redirect stderr
}
if (session->config->ldpaths)
- afb_apis_add_pathset(session->config->ldpaths);
+ afb_api_so_add_pathset(session->config->ldpaths);
- ctxStoreInit(CTX_NBCLIENTS, session->config->cntxTimeout, afb_apis_count(), session->config->token);
+ ctxStoreInit(CTX_NBCLIENTS, session->config->cntxTimeout, session->config->token);
+ if (!afb_hreq_init_cookie(session->config->httpdPort, session->config->rootapi, DEFLT_CNTX_TIMEOUT)) {
+ fprintf (stderr, "ERR: initialisation of cookies failed\n");
+ exit (1);
+ }
install_error_handlers();
// --------- run -----------
if (session->background) {
// --------- in background mode -----------
- if (verbosity) printf ("AFB: Entering background mode\n");
+ if (verbosity) fprintf (stderr, "AFB: Entering background mode\n");
daemonize(session);
} else {
// ---- in foreground mode --------------------
{
int idx;
- if (!afb_hsrv_add_handler(hsrv, config->rootapi, afb_hreq_websocket_switch, NULL, 20))
+ if (!afb_hsrv_add_handler(hsrv, config->rootapi, afb_hswitch_websocket_switch, NULL, 20))
return 0;
- if (!afb_hsrv_add_handler(hsrv, config->rootapi, afb_hreq_rest_api, NULL, 10))
+ if (!afb_hsrv_add_handler(hsrv, config->rootapi, afb_hswitch_apis, NULL, 10))
return 0;
for (idx = 0; config->aliasdir[idx].url != NULL; idx++)
if (!afb_hsrv_add_alias(hsrv, "", config->rootdir, -10))
return 0;
- if (!afb_hsrv_add_handler(hsrv, config->rootbase, afb_hreq_one_page_api_redirect, NULL, -20))
+ if (!afb_hsrv_add_handler(hsrv, config->rootbase, afb_hswitch_one_page_api_redirect, NULL, -20))
return 0;
return 1;
if (!afb_hsrv_set_cache_timeout(hsrv, config->cacheTimeout)
|| !init(hsrv, config)) {
- printf("Error: initialisation of httpd failed");
+ fprintf (stderr, "Error: initialisation of httpd failed");
afb_hsrv_put(hsrv);
return NULL;
}
if (verbosity) {
- printf("AFB:notice Waiting port=%d rootdir=%s\n", config->httpdPort, config->rootdir);
- printf("AFB:notice Browser URL= http:/*localhost:%d\n", config->httpdPort);
+ fprintf (stderr, "AFB:notice Waiting port=%d rootdir=%s\n", config->httpdPort, config->rootdir);
+ fprintf (stderr, "AFB:notice Browser URL= http:/*localhost:%d\n", config->httpdPort);
}
rc = afb_hsrv_start(hsrv, (uint16_t) config->httpdPort, 15);
if (!rc) {
- printf("Error: starting of httpd failed");
+ fprintf (stderr, "Error: starting of httpd failed");
afb_hsrv_put(hsrv);
return NULL;
}