/*
- * Copyright (C) 2016, 2017, 2018 "IoT.bzh"
+ * Copyright (C) 2016-2019 "IoT.bzh"
* Author José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
#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;
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;
}
}
/* 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 */
/* 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:
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);