afs-supervisor: Add systemd service and config
authorJosé Bollo <jose.bollo@iot.bzh>
Mon, 26 Feb 2018 17:57:24 +0000 (18:57 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Mon, 26 Feb 2018 18:04:53 +0000 (19:04 +0100)
Change-Id: I64bf8de01dbb8cf9581ed0be358d81fa84106520
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
CMakeLists.txt
afs-supervisor.service.in [new file with mode: 0644]
src/CMakeLists.txt

index 1a6d218..b784621 100644 (file)
@@ -39,6 +39,11 @@ INCLUDE(CTest)
 # possible settings
 set(AGL_DEVEL OFF CACHE BOOL "Activates developping features")
 set(INCLUDE_MONITORING OFF CACHE BOOL "Activates installation of monitoring")
+set(INCLUDE_SUPERVISOR OFF CACHE BOOL "Activates installation of supervisor")
+set(AFS_SURPERVISION_SOCKET "@urn:AGL:afs:supervision:socket" CACHE STRING "Internal socket for supervision")
+set(AFS_SUPERVISOR_PORT 1619 CACHE STRING "Port of service for the supervisor")
+set(AFS_SUPERVISOR_TOKEN HELLO CACHE STRING "Secret token for the supervisor")
+set(UNITDIR_SYSTEM ${CMAKE_INSTALL_LIBDIR}/systemd/system CACHE STRING "Path to systemd system unit files")
 
 ###########################################################################
 
@@ -80,6 +85,8 @@ PKG_CHECK_MODULES(openssl openssl)
 PKG_CHECK_MODULES(uuid uuid)
 PKG_CHECK_MODULES(cynara cynara-client)
 
+ADD_DEFINITIONS("-DAFS_SURPERVISION_SOCKET=\"${AFS_SURPERVISION_SOCKET}\"")
+
 IF(AGL_DEVEL)
        ADD_DEFINITIONS(-DAGL_DEVEL)
 endif()
@@ -176,3 +183,13 @@ ELSE()
        )
 
 ENDIF()
+
+IF(INCLUDE_SUPERVISOR)
+       CONFIGURE_FILE(afs-supervisor.service.in afs-supervisor.service @ONLY)
+       INSTALL(FILES
+           ${CMAKE_CURRENT_BINARY_DIR}/afs-supervisor.service
+           DESTINATION
+           ${UNITDIR_SYSTEM}
+       )
+ENDIF()
+
diff --git a/afs-supervisor.service.in b/afs-supervisor.service.in
new file mode 100644 (file)
index 0000000..60b2a31
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=Application Framework Supervisor
+
+[Service]
+ExecStart=/usr/bin/afs-supervisor --port @AFS_SUPERVISOR_PORT@ --token @AFS_SUPERVISOR_TOKEN@
+
+[Install]
+WantedBy=multi-user.target
+
index bfe187f..d7cde90 100644 (file)
@@ -89,13 +89,15 @@ INSTALL(TARGETS afb-daemon
 ###########################################
 # build and install afb-daemon
 ###########################################
-ADD_EXECUTABLE(afs-supervisor afs-main.c afs-supervisor.c afs-discover.c afs-config.c)
-TARGET_LINK_LIBRARIES(afs-supervisor
-       afb-lib
-       ${link_libraries}
-)
-INSTALL(TARGETS afs-supervisor
-        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+IF(INCLUDE_SUPERVISOR)
+       ADD_EXECUTABLE(afs-supervisor afs-main.c afs-supervisor.c afs-discover.c afs-config.c)
+       TARGET_LINK_LIBRARIES(afs-supervisor
+               afb-lib
+               ${link_libraries}
+       )
+       INSTALL(TARGETS afs-supervisor
+               RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ENDIF()
 
 ###########################################
 # build and install libafbwsc