From e02a10dac7d80b3ee025a3a605d1016006e539f6 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Tue, 6 Jun 2017 14:21:51 +0200 Subject: Adding service files for running http-server as a systemd service Change-Id: If033d8c1526a118bc902c4fc3717b05d0b422a5d Signed-off-by: Mauro Sardara --- CMakeLists.txt | 18 ++++++++++++------ README.md | 2 +- config/hicn-http-server.service | 29 +++++++++++++++++++++++++++++ config/http-server.service | 29 +++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 config/hicn-http-server.service create mode 100644 config/http-server.service diff --git a/CMakeLists.txt b/CMakeLists.txt index f909c9c1..14e7db16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 (msardara@cisco.com)" 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}) diff --git a/README.md b/README.md index f5538372..e40ba2ab 100644 --- 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 index 00000000..20b73c38 --- /dev/null +++ b/config/hicn-http-server.service @@ -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 . +# +# Author: Mauro Sardara + +[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 index 00000000..75a4f7b0 --- /dev/null +++ b/config/http-server.service @@ -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 . +# +# Author: Mauro Sardara + +[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 -- cgit 1.2.3-korg