Beginning of integration as systemd service
[src/app-framework-binder.git] / src / main.c
index 774a5f0..f1ebd96 100644 (file)
@@ -28,6 +28,9 @@
 #include <sys/wait.h>
 
 #include <systemd/sd-event.h>
+#include <systemd/sd-daemon.h>
+
+#include <afb/afb-binding.h>
 
 #include "afb-config.h"
 #include "afb-hswitch.h"
@@ -44,8 +47,7 @@
 #include "verbose.h"
 #include "afb-common.h"
 #include "afb-hook.h"
-
-#include <afb/afb-binding.h>
+#include "sd-fds.h"
 
 /*
    if SELF_PGROUP == 0 the launched command is the group leader
@@ -358,6 +360,8 @@ int main(int argc, char *argv[])
 
        LOGAUTH("afb-daemon");
 
+       sd_fds_init();
+
        // ------------- Build session handler & init config -------
        config = afb_config_parse_arguments(argc, argv);
        atexit(exit_handler);
@@ -374,13 +378,14 @@ int main(int argc, char *argv[])
                exit(1);
        }
 
-       afb_session_init(config->nbSessionMax, config->cntxTimeout, config->token, afb_apis_count());
-
        afb_api_so_set_timeout(config->apiTimeout);
        start_list(config->dbus_clients, afb_api_dbus_add_client, "the afb-dbus client");
        start_list(config->ws_clients, afb_api_ws_add_client, "the afb-websocket client");
        start_list(config->ldpaths, afb_api_so_add_pathset, "the binding path set");
        start_list(config->so_bindings, afb_api_so_add_binding, "the binding");
+
+       afb_session_init(config->nbSessionMax, config->cntxTimeout, config->token, afb_apis_count());
+
        start_list(config->dbus_servers, afb_api_dbus_add_server, "the afb-dbus service");
        start_list(config->ws_servers, afb_api_ws_add_server, "the afb-websocket service");
 
@@ -454,6 +459,7 @@ int main(int argc, char *argv[])
 
        // infinite loop
        eventloop = afb_common_get_event_loop();
+       sd_notify(1, "READY=1");
        for (;;)
                sd_event_run(eventloop, 30000000);