Adding service files for running http-server as a systemd service 21/7021/2
authorMauro Sardara <[email protected]>
Tue, 6 Jun 2017 12:21:51 +0000 (14:21 +0200)
committerMauro Sardara <[email protected]>
Tue, 6 Jun 2017 14:31:16 +0000 (16:31 +0200)
Change-Id: If033d8c1526a118bc902c4fc3717b05d0b422a5d
Signed-off-by: Mauro Sardara <[email protected]>
CMakeLists.txt
README.md
config/hicn-http-server.service [new file with mode: 0644]
config/http-server.service [new file with mode: 0644]

index f909c9c..14e7db1 100644 (file)
@@ -27,11 +27,13 @@ option(HICNET "Link against Libhicnet." OFF)
 
 if (HICNET)
     find_package(Libhicnet REQUIRED)
-    set (TRANSPORT_LIBRARY HICNET)
+    set(TRANSPORT_LIBRARY HICNET)
     set(ICNET OFF)
+    set(PREFIX "hicn-")
 else()
     find_package(Libicnet REQUIRED)
-    set (TRANSPORT_LIBRARY ICNET)
+    set(TRANSPORT_LIBRARY ICNET)
+    set(PREFIX "")
 endif()
 
 configure_file("${PROJECT_SOURCE_DIR}/config.h.in"
@@ -77,10 +79,10 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS} -fper
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS} -fpermissive")
 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS} -fpermissive")
 
-add_executable(http-server ${SOURCE_FILES})
-target_link_libraries(http-server ${LIB${TRANSPORT_LIBRARY}_LIBRARY} ${CURL_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+add_executable(${PREFIX}http-server ${SOURCE_FILES})
+target_link_libraries(${PREFIX}http-server ${LIB${TRANSPORT_LIBRARY}_LIBRARY} ${CURL_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
 
-install(TARGETS http-server DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+install(TARGETS ${PREFIX}http-server DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
 
 # Generate DEB / RPM packages
 
@@ -93,7 +95,7 @@ set(DISTRIBUTION "xenial" CACHE STRING "Distribution")
 set(ARCHITECTURE "amd64" CACHE STRING "Architecture")
 set(PACKAGE_MAINTAINER "Mauro Sardara ([email protected])" CACHE STRING "Maintainer")
 set(BUILD_NUMBER "1" CACHE STRING "Build Number")
-string(TOLOWER ${CMAKE_PROJECT_NAME} PACKAGE_NAME)
+string(TOLOWER ${PREFIX}${CMAKE_PROJECT_NAME} PACKAGE_NAME)
 
 set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
 set(CPACK_PACKAGE_VENDOR ${VENDOR})
@@ -123,6 +125,10 @@ else ()
     return()
 endif ()
 
+# Install also configuration files
+set (HTTP_SERVER_SERVICE ${PROJECT_SOURCE_DIR}/config/${PREFIX}http-server.service)
+install(FILES ${HTTP_SERVER_SERVICE} DESTINATION /lib/systemd/system RENAME ${PREFIX}http-server.service)
+
 set(CPACK_GENERATOR ${GENERATOR})
 set(CPACK_${TYPE}_PACKAGE_MAINTAINER ${PACKAGE_MAINTAINER})
 set(CPACK_${TYPE}_PACKAGE_NAME ${PACKAGE_NAME})
index f553837..e40ba2a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -122,4 +122,4 @@ Http-server has been tested in:
     - Ubuntu 14.04 (x86_64)
     - Debian Testing
     - MacOSX 10.12
-    - CentOS 7
+    - CentOS 7
\ No newline at end of file
diff --git a/config/hicn-http-server.service b/config/hicn-http-server.service
new file mode 100644 (file)
index 0000000..20b73c3
--- /dev/null
@@ -0,0 +1,29 @@
+# Copyright (c) 2015,  Cisco Systems
+#
+# This file is part of the NDN connectivity-manager.
+# See AUTHORS.md for complete list of authors and contributors.
+#
+# This program is free software: you can redistribute it and/or modify it under the terms
+# of the GNU General Public License as published by the Free Software Foundation,
+# either version 3 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Mauro Sardara <[email protected]>
+
+[Unit]
+Description=Http Server using tcp/icn as tranport protocol
+#Documentation=man:http-server
+Requires=hicn-forwarder.service
+
+[Service]
+ExecStart=/usr/bin/hicn-http-server
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/http-server.service b/config/http-server.service
new file mode 100644 (file)
index 0000000..75a4f7b
--- /dev/null
@@ -0,0 +1,29 @@
+# Copyright (c) 2015,  Cisco Systems
+#
+# This file is part of the NDN connectivity-manager.
+# See AUTHORS.md for complete list of authors and contributors.
+#
+# This program is free software: you can redistribute it and/or modify it under the terms
+# of the GNU General Public License as published by the Free Software Foundation,
+# either version 3 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Mauro Sardara <[email protected]>
+
+[Unit]
+Description=Http Server using tcp/icn as tranport protocol
+#Documentation=man:http-server
+Requires=metis-forwarder.service
+
+[Service]
+ExecStart=/usr/bin/http-server
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target