- int rc, fd;
-
- /* check argument */
- if (!spec) {
- ERROR("invalid socket spec");
- return -1;
- }
-
- rc = afb_session_init(100, 600, "");
- /* TODO check that value */
-
- /* create the apisets */
- main_apiset = afb_apiset_create(supervisor_apiname, 0);
- if (!main_apiset) {
- ERROR("Can't create supervisor's apiset");
- return -1;
- }
- empty_apiset = afb_apiset_create(supervision_apiname, 0);
- if (!empty_apiset) {
- ERROR("Can't create supervision apiset");
- return -1;
- }
-
-
- /* init the main apiset */
- rc = afb_init_supervision_api();
- if (rc < 0) {
- ERROR("Can't create supervision's apiset: %m");
- return -1;
- }
-
- /* create the supervision socket */
- fd = create_supervision_socket(supervision_socket_path);
- if (fd < 0)
- return fd;
-
- /* listen the socket */
- rc = listen(fd, 5);
- if (rc < 0) {
- ERROR("refused to listen on socket");
- return rc;
- }
-
- /* integrate the socket to the loop */
- rc = sd_event_add_io(afb_common_get_event_loop(),
- NULL, fd, EPOLLIN,
- listening, NULL);
- if (rc < 0) {
- ERROR("handling socket event isn't possible");
- return rc;
- }