X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fmain-afs-supervisor.c;h=9b8b6d129bad33f6865cd34033f2571246e92829;hb=65353dce81a629e042800bb7b86fcd869a76727e;hp=14f1c3b00d76ff901039198f79e92a5e3747284e;hpb=4521c1e7ae5371ab9d639adc617d17fb4e8ded0c;p=src%2Fapp-framework-binder.git diff --git a/src/main-afs-supervisor.c b/src/main-afs-supervisor.c index 14f1c3b0..9b8b6d12 100644 --- a/src/main-afs-supervisor.c +++ b/src/main-afs-supervisor.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017, 2018 "IoT.bzh" + * Copyright (C) 2015-2020 "IoT.bzh" * Author José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,14 +34,19 @@ #include "afb-session.h" #include "afs-supervisor.h" -#include "afs-config.h" +#include "afs-args.h" #include "verbose.h" #include "jobs.h" #include "process-name.h" +#include "watchdog.h" + +#if !defined(DEFAULT_SUPERVISOR_INTERFACE) +# define DEFAULT_SUPERVISOR_INTERFACE NULL +#endif /* the main config */ -struct afs_config *main_config; +struct afs_args *main_config; /* the main apiset */ struct afb_apiset *main_apiset; @@ -99,13 +104,20 @@ static struct afb_hsrv *start_http_server() NOTICE("Waiting port=%d rootdir=%s", main_config->httpdPort, main_config->rootdir); NOTICE("Browser URL= http://localhost:%d", main_config->httpdPort); - rc = afb_hsrv_start(hsrv, (uint16_t) main_config->httpdPort, 15); + rc = afb_hsrv_start(hsrv, 15); if (!rc) { ERROR("starting of httpd failed"); afb_hsrv_put(hsrv); return NULL; } + rc = afb_hsrv_add_interface_tcp(hsrv, DEFAULT_SUPERVISOR_INTERFACE, (uint16_t) main_config->httpdPort); + if (!rc) { + ERROR("setting interface failed"); + afb_hsrv_put(hsrv); + return NULL; + } + return hsrv; } @@ -132,7 +144,7 @@ static void start(int signum, void *arg) } /* configure the daemon */ - if (afb_session_init(main_config->nbSessionMax, main_config->cntxTimeout, main_config->token)) { + if (afb_session_init(main_config->nbSessionMax, main_config->cntxTimeout)) { ERROR("initialisation of session manager failed"); goto error; } @@ -160,7 +172,7 @@ static void start(int signum, void *arg) } /* start the services */ - if (afb_apiset_start_all_services(main_apiset, 1) < 0) + if (afb_apiset_start_all_services(main_apiset) < 0) goto error; /* start the HTTP server */ @@ -180,6 +192,14 @@ static void start(int signum, void *arg) /* ready */ sd_notify(1, "READY=1"); + + /* activate the watchdog */ +#if HAS_WATCHDOG + if (watchdog_activate() < 0) + ERROR("can't start the watchdog"); +#endif + + /* discover binders */ afs_supervisor_discover(); return; error: @@ -192,7 +212,7 @@ error: int main(int ac, char **av) { /* scan arguments */ - main_config = afs_config_parse_arguments(ac, av); + main_config = afs_args_parse(ac, av); if (main_config->name) { verbose_set_name(main_config->name, 0); process_name_set_name(main_config->name);