Add systemd unit file to start X52 daemon

reverse-scroll
nirenjan 2021-08-05 10:21:28 -07:00
parent 7f5b5a2eaf
commit 0cf6f247be
4 changed files with 58 additions and 2 deletions

View File

@ -77,3 +77,21 @@ the following argument to `configure`:
``` ```
--with-input-group=group --with-input-group=group
``` ```
### Systemd support
The X52 daemon can run either as a foreground process, or it can daemonize
itself to run in the background. Typical deployments with systemd will have it
run in the foreground, and disable timestamps in the logs, since those are
inserted automatically by journald.
Systemd support is enabled by default, but can be disabled with the
`--disable-systemd` argument to `configure`
It is also possible to configure the directory in which the service file is
installed with the following option. This is ignored if you have specified
`--disable-systemd`.
```
--with-systemdsystemunitdir=/path/to/systemd/system
```

View File

@ -11,6 +11,7 @@ AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_PROG_CC AC_PROG_CC
AC_PROG_CC_STDC AC_PROG_CC_STDC
AC_PROG_AWK AC_PROG_AWK
AC_PROG_SED
AM_PROG_AR AM_PROG_AR
AM_PATH_PYTHON([3.5]) AM_PATH_PYTHON([3.5])
LT_INIT LT_INIT
@ -51,9 +52,29 @@ PKG_CHECK_MODULES([INIH], [inih], [],
AC_SEARCH_LIBS([ini_parse], [inih]) AC_SEARCH_LIBS([ini_parse], [inih])
]) ])
# Pinelog configuration # systemd support
AC_SUBST([PINELOG_CFLAGS], ["-DPINELOG_SHOW_DATE=1 -DPINELOG_SHOW_LEVEL=1 -DPINELOG_SHOW_BACKTRACE=1"]) PKG_CHECK_MODULES([SYSTEMD], [systemd], [have_systemd=yes], [have_systemd=no])
AC_ARG_ENABLE([systemd],
[AS_HELP_STRING([--disable-systemd], [Disable systemd support])]
)
AC_ARG_WITH([systemdsystemunitdir],
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd unit files])],
[systemdsystemunitdir=$withval],
[systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)]
)
AC_SUBST([systemdsystemunitdir], [$systemdsystemunitdir])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$have_systemd" = "xyes" -a "x$enable_systemd" != "xno"])
AM_COND_IF([HAVE_SYSTEMD],,
[
AC_MSG_NOTICE([systemd not found or disabled. Enabling timestamps in logs])
AX_APPEND_FLAG([-DPINELOG_SHOW_DATE=1], [PINELOG_CFLAGS])
]
)
# Pinelog configuration
AX_APPEND_FLAG([-DPINELOG_SHOW_LEVEL=1], [PINELOG_CFLAGS])
AX_APPEND_FLAG([-DPINELOG_SHOW_BACKTRACE=1], [PINELOG_CFLAGS])
AC_SUBST([PINELOG_CFLAGS])
# Check for hidapi. This uses a different pkg-config file on Linux vs other # Check for hidapi. This uses a different pkg-config file on Linux vs other
# hosts, so check accordingly # hosts, so check accordingly

View File

@ -37,9 +37,19 @@ x52dconf_DATA = daemon/x52d.conf
EXTRA_DIST += \ EXTRA_DIST += \
daemon/daemon.dox \ daemon/daemon.dox \
daemon/x52d.service.in \
daemon/x52d_clock.h \ daemon/x52d_clock.h \
daemon/x52d_config.def \ daemon/x52d_config.def \
daemon/x52d_config.h \ daemon/x52d_config.h \
daemon/x52d_const.h \ daemon/x52d_const.h \
daemon/x52d_device.h \ daemon/x52d_device.h \
daemon/x52d.conf daemon/x52d.conf
if HAVE_SYSTEMD
if !IS_MAKE_DISTCHECK
SED_ARGS = s,%bindir%,$(bindir),g
x52d.service: daemon/x52d.service.in
$(AM_V_GEN) $(SED) -e '$(SED_ARGS)' $< > $@
systemdsystemunit_DATA = x52d.service
endif
endif

View File

@ -0,0 +1,7 @@
[Unit]
Description=X52 driver daemon
[Service]
Type=simple
ExecStart=%bindir%/x52d -f
ExecReload=kill -HUP $MAINPID