From 5a7094b22c9bc07ea7bfd591990fd8c9f2ac6419 Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Wed, 10 Apr 2019 19:33:15 -0400 Subject: Add systemd unit files Add bmcweb.socket, a systemd unit file that enables systemd socket activation of bmcweb. Systemd socket activation defers startup of socket listening applications until something connects to the socket. There are presently no configurable parameters in bmcweb.socket. Add bmcweb.service, a systemd unit file for starting bmcweb. bmcweb.service has one configurable parameter, the installation prefix. Prior these unit files were hosted in the meta-phosphor repository but OpenBMC is moving away from unit-files-in-metadata and trying to do it the way the rest of the world does it - unit files are provided by the projects that contain the application source. The unit files were copied mostly verbatim (minor update for installation prefix in bmcweb.service template) so the only new logic here is in the cmake logic. Tested by: 1 - devtool add bmcweb. 2 - apply this diff to bmcweb_git.bb: -inherit obmc-phosphor-systemd +inherit systemd 3 - bitbake bmcweb. 4 - manual inspection of the image dir in the yocto build tree. Change-Id: I61b49d519f5b4eb06e97a14d4f6707344e544434 Signed-off-by: Brad Bishop --- CMakeLists.txt | 13 +++++++++++++ bmcweb.service.in | 13 +++++++++++++ bmcweb.socket | 9 +++++++++ 3 files changed, 35 insertions(+) create mode 100644 bmcweb.service.in create mode 100644 bmcweb.socket diff --git a/CMakeLists.txt b/CMakeLists.txt index 28fbe0f..7cde52e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -273,3 +273,16 @@ target_compile_definitions ( $<$: -DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES> ) + +# configure and install systemd unit files +configure_file (bmcweb.socket bmcweb.socket COPYONLY) +configure_file (bmcweb.service.in bmcweb.service) +pkg_get_variable (SYSTEMD_SYSTEMUNITDIR systemd systemdsystemunitdir) +install ( + FILES ${PROJECT_BINARY_DIR}/bmcweb.socket + DESTINATION ${SYSTEMD_SYSTEMUNITDIR} +) +install ( + FILES ${PROJECT_BINARY_DIR}/bmcweb.service + DESTINATION ${SYSTEMD_SYSTEMUNITDIR} +) diff --git a/bmcweb.service.in b/bmcweb.service.in new file mode 100644 index 0000000..644ecca --- /dev/null +++ b/bmcweb.service.in @@ -0,0 +1,13 @@ +[Unit] +Description=Start bmcweb server + +Wants=network.target +After=network.target + +[Service] +ExecStart=@CMAKE_INSTALL_PREFIX@/bin/bmcweb +Type=simple +WorkingDirectory=/home/root + +[Install] +WantedBy=network.target diff --git a/bmcweb.socket b/bmcweb.socket new file mode 100644 index 0000000..8782e4d --- /dev/null +++ b/bmcweb.socket @@ -0,0 +1,9 @@ +[Unit] +Description=BMC Webserver socket + +[Socket] +ListenStream=443 +ReusePort=true + +[Install] +WantedBy=sockets.target -- cgit v1.2.1