Skip to content

Commit

Permalink
Add hwloc-dump-hwdata.service systemd service file
Browse files Browse the repository at this point in the history
It lets systemd run hwloc-dump-hwdata at startup.
We don't install the file but rather let packagers install it for now.

Thanks to Grzegorz Andrejczuk.
  • Loading branch information
bgoglin committed Apr 12, 2016
1 parent 329c1d2 commit 21d3f57
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SUBDIRS += netloc
endif

if HWLOC_BUILD_STANDALONE
SUBDIRS += tests utils contrib/misc
SUBDIRS += tests utils contrib/systemd contrib/misc
# We need doc/ if HWLOC_BUILD_DOXYGEN, or during make install if HWLOC_INSTALL_DOXYGEN.
# There's no INSTALL_SUBDIRS, so always enter doc/ and check HWLOC_BUILD/INSTALL_DOXYGEN there
SUBDIRS += doc
Expand Down
3 changes: 3 additions & 0 deletions config/hwloc_internal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ EOF
LIBS="$hwloc_old_LIBS"
unset hwloc_old_LIBS
AC_PATH_TOOL(RMPATH, rm)
_HWLOC_CHECK_DIFF_U
_HWLOC_CHECK_DIFF_W
Expand Down Expand Up @@ -412,6 +414,7 @@ int foo(void) {
hwloc_config_prefix[utils/hwloc/test-fake-plugin.sh]
hwloc_config_prefix[utils/lstopo/test-lstopo.sh]
hwloc_config_prefix[utils/lstopo/test-lstopo-distances.sh]
hwloc_config_prefix[contrib/systemd/Makefile]
hwloc_config_prefix[contrib/misc/Makefile]
hwloc_config_prefix[tests/netloc/Makefile]
)
Expand Down
22 changes: 22 additions & 0 deletions contrib/systemd/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright © 2016 Inria. All rights reserved.
# See COPYING in top-level directory.

# We can't use autoconf because we don't want $sbindir to be replaced with ${exec_prefix}/sbin
# Also don't install since , let the packagers do it.

EXTRA_DIST = hwloc-dump-hwdata.service.in

if HWLOC_HAVE_LINUX
nodist_pkgdata_DATA = hwloc-dump-hwdata.service
# depend on Makefile in case we rerun configure with different directory arguments
hwloc-dump-hwdata.service: hwloc-dump-hwdata.service.in Makefile
@echo Creating $@...
@ $(SED) \
-e 's@#SBINDIR#@'$(sbindir)'@g' \
-e 's@#RUNSTATEDIR#@'$(HWLOC_runstatedir)'@g' \
-e 's@#RMPATH#@'$(RMPATH)'@g' \
> $@ < $<

distclean-local:
rm -f hwloc-dump-hwdata.service
endif
22 changes: 22 additions & 0 deletions contrib/systemd/hwloc-dump-hwdata.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright © 2015-2016 Intel, Inc. All rights reserved.
# Copyright © 2016 Inria. All rights reserved.
# See COPYING in top-level directory.
#
# #RUNSTATEDIR#/hwloc was specified at configure time.
# It may be changed by passing configure options such as --runstatedir,
# --localstatedir or --prefix.
# It may also be manually changed before installing this file in systemd directories.
#

[Unit]
Description=Dump hardware topology and locality information to #RUNSTATEDIR#/hwloc

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=#SBINDIR#/hwloc-dump-hwdata -o #RUNSTATEDIR#/hwloc
ExecStop=#RMPATH# -rf #RUNSTATEDIR#/hwloc

[Install]
WantedBy=multi-user.target

0 comments on commit 21d3f57

Please sign in to comment.