From patchwork Tue May 1 15:07:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masayoshi Mizuma X-Patchwork-Id: 10374065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0B8836053D for ; Tue, 1 May 2018 15:07:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3B43223A6 for ; Tue, 1 May 2018 15:07:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3A222624C; Tue, 1 May 2018 15:07:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID,URIBL_BLACK autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 28C92223A6 for ; Tue, 1 May 2018 15:07:09 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5E0502007E7F6; Tue, 1 May 2018 08:07:09 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4003:c0f::243; helo=mail-ot0-x243.google.com; envelope-from=msys.mizuma@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-ot0-x243.google.com (mail-ot0-x243.google.com [IPv6:2607:f8b0:4003:c0f::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 52B632007E7E3 for ; Tue, 1 May 2018 08:07:08 -0700 (PDT) Received: by mail-ot0-x243.google.com with SMTP id o8-v6so4464626ota.12 for ; Tue, 01 May 2018 08:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=FafrL7b0xM0eR6xwSWgN5thgzkP68Z20dgn8rKwsQWM=; b=rsauuAXTlE/zU3KM7uOc6K9m0t3vmwghg8lWcQ44bKNHWh7VM/f8YXfKGhsWTTuuj9 3bgGXSOKKicleFA4pN7yhsWKwhBlvTmNIm/JzMuSHXcWk/dZsZfWIuxRbCPW6b9c2yKA uw6PysEU8hzTUVSlQTI8Pr8V6ypnRlidSPmDjMlg6a3qLf24PYlH+e/+VjeReHYHZFGD QfyiDO5T92fTk3OPmOP2AsUSfZ/yh84sKveorvTWxkFrKu6BzCOetaEfCFsNGIAkMJD7 kVnkIQWYIO466jZWRkuglJEOtcaOzFcoqCGNv8SU18y+2ouuwm7INZlWTLlHef0e9Cd8 uT8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FafrL7b0xM0eR6xwSWgN5thgzkP68Z20dgn8rKwsQWM=; b=qttmYt0n/V/Qeh/ThS+citm6UReBX6OSZqI835t+U35mnsxUTSxtzDgkbe+YDMdNDi +enC+/oUAKWDd91cq49v57/c4rNu6agsAE2mimYqhgqDnDweRv81Hr/R5EgIYHGaKnbT phAfuHzv3LYfIjgItVc8gEl19A6S29nKBnWur5Urt+Da/gl+VFo+vF/amag4W52MzucD oSTtfNj1cgnj72I3nS/qLFLcrzqrcyy2fFBJEzxrj5HLszENNH1CxCe3/YM3FxZRwlRo ZDq8tNZZ5JKqNEc0nfNKe909QBOkbQ98mP5vR5SH3Wd6kC3nEvNTZ8GugAx24xuSWZ4L 3EqQ== X-Gm-Message-State: ALQs6tCmo8k9MLUEp5Ri7PhKvIkjtAhl+VbbMkd7dA+9lfqMOcRAM1i1 SVztpnGOS4vybz5q9Wpq7wtIn+8= X-Google-Smtp-Source: AB8JxZr4PgAiCrA2WMak8DnoSatAP47YbsnnNQrQcCYpmfX606zv3icy1/LTC1WZJRgSMsofbohXUg== X-Received: by 2002:a9d:3f34:: with SMTP id m49-v6mr11697814otc.80.1525187226928; Tue, 01 May 2018 08:07:06 -0700 (PDT) Received: from [10.18.17.172] (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id t197-v6sm5685279oih.36.2018.05.01.08.07.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 08:07:06 -0700 (PDT) Subject: Re: [PATCH v5 4/4] ndctl, monitor: add the unit file of systemd for ndctl-monitor service To: qi.fuli@jp.fujitsu.com, linux-nvdimm@lists.01.org References: <20180426113050.11424-1-qi.fuli@jp.fujitsu.com> <20180426113050.11424-5-qi.fuli@jp.fujitsu.com> From: Masayoshi Mizuma Message-ID: <4ee59ab2-7c2f-1444-5e27-fda231982b0d@gmail.com> Date: Tue, 1 May 2018 11:07:05 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180426113050.11424-5-qi.fuli@jp.fujitsu.com> Content-Language: en-US X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Hello QI, I think the systemd service is nice, however, it seems that it does not work fine... because ndctl-monitor.service was not installed to systemd dir. On 04/26/2018 07:30 AM, QI Fuli wrote: > This patch adds the systemd unit file for ndctl-monitor service. > The systemd unit directory can be configured by setting environment > variable "--with-systemd-unit-dir[=DIR]". > > Signed-off-by: QI Fuli > > --- > autogen.sh | 3 ++- > configure.ac | 22 ++++++++++++++++++++++ > ndctl/Makefile.am | 4 ++++ > ndctl/ndctl-monitor.service | 7 +++++++ > 4 files changed, 35 insertions(+), 1 deletion(-) > create mode 100644 ndctl/ndctl-monitor.service > > diff --git a/autogen.sh b/autogen.sh > index a23cf53..b226c7a 100755 > --- a/autogen.sh > +++ b/autogen.sh > @@ -17,7 +17,8 @@ libdir() { > > args="--prefix=/usr \ > --sysconfdir=/etc \ > ---libdir=$(libdir /usr/lib)" > +--libdir=$(libdir /usr/lib) \ > +--with-systemd-unit-dir" > > echo > echo "----------------------------------------------------------------" > diff --git a/configure.ac b/configure.ac > index cddad16..60c6537 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -135,6 +135,27 @@ AC_CHECK_FUNCS([ \ > secure_getenv\ > ]) > > +PKG_PROG_PKG_CONFIG > +AC_ARG_WITH([systemd-unit-dir], > + AS_HELP_STRING([--with-systemd-unit-dir[=DIR]], > + [Directory for systemd service files]), > + [], > + [with_systemd_unit_dir=yes]) > + > +if test "x$with_systemd_unit_dir" = "xyes"; then > + def_systemd_unit_dir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) > + if test "x$def_systemd_unit_dir" = "x"; then > + AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package]) > + with_systemd_unit_dir=no > + else > + with_systemd_unit_dir="$def_systemd_unit_dir" > + fi > +fi > + > +AS_IF([test "x$with_systemd_unit_dir" != "xno"], > + [AC_SUBST([SYSTEMD_UNIT_DIR], [$with_systemd_unit_dir])]) > +AM_CONDITIONAL([ENABLE_SYSTEMD_UNIT_DIR], [test "x$with_systemd_unit_dir" != "xno"]) > + > my_CFLAGS="\ > -Wall \ > -Wchar-subscripts \ > @@ -172,6 +193,7 @@ AC_MSG_RESULT([ > sysconfdir: ${sysconfdir} > libdir: ${libdir} > includedir: ${includedir} > + systemd-unit-dir: ${SYSTEMD_UNIT_DIR} > > compiler: ${CC} > cflags: ${CFLAGS} > diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am > index ae3d894..b3053d0 100644 > --- a/ndctl/Makefile.am > +++ b/ndctl/Makefile.am > @@ -47,3 +47,7 @@ monitor_config_file = monitor.conf > monitor_configdir = /etc/ndctl/ > monitor_config_DATA = $(monitor_config_file) > EXTRA_DIST += $(monitor_config_file) > + > +if ENABLE_SYSTEMD_UNIT_DIR > +systemd_unitDATA = ndctl-monitor.service > +endif I'm not familiar with autoconf syntax, but I think the 'systemd_unitDATA' may be wrong... *_DATA is correct, isn't it? And, your autoconf code is a little different from the example of autoconf guide for systemd [1]. It might be a good idea to use the example code simply because it makes easy to find the systemd code for someone who try to add systemd service in the future. [1] https://www.freedesktop.org/software/systemd/man/daemon.html > diff --git a/ndctl/ndctl-monitor.service b/ndctl/ndctl-monitor.service > new file mode 100644 > index 0000000..44f9326 > --- /dev/null > +++ b/ndctl/ndctl-monitor.service > @@ -0,0 +1,7 @@ > +[Unit] > +Description=Ndctl Monitor Daemon > + > +[Service] > +Type=forking > +ExecStart=/usr/bin/ndctl monitor --daemon > +ExecStop=/bin/kill ${MAINPID} > How about the following change? --- autogen.sh | 3 ++- configure.ac | 15 +++++++++++++++ ndctl/Makefile.am | 4 ++++ ndctl/ndctl-monitor.service | 7 +++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 ndctl/ndctl-monitor.service diff --git a/autogen.sh b/autogen.sh index a23cf53..bc58002 100755 --- a/autogen.sh +++ b/autogen.sh @@ -17,7 +17,8 @@ libdir() { args="--prefix=/usr \ --sysconfdir=/etc \ ---libdir=$(libdir /usr/lib)" +--libdir=$(libdir /usr/lib) \ +--with-systemdsystemunitdir" echo echo "----------------------------------------------------------------" diff --git a/configure.ac b/configure.ac index 3eaac32..6fe054f 100644 --- a/configure.ac +++ b/configure.ac @@ -122,6 +122,20 @@ AC_CHECK_FUNCS([ \ secure_getenv\ ]) +AC_ARG_WITH([systemdsystemunitdir], + [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],, + [with_systemdsystemunitdir=auto]) +AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], + [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) + AS_IF([test "x$def_systemdsystemunitdir" = "x"], + [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], + [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]) + with_systemdsystemunitdir=no], + [with_systemdsystemunitdir="$def_systemdsystemunitdir"])]) +AS_IF([test "x$with_systemdsystemunitdir" != "xno"], + [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]) +AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) + my_CFLAGS="\ -Wall \ -Wchar-subscripts \ @@ -159,6 +173,7 @@ AC_MSG_RESULT([ sysconfdir: ${sysconfdir} libdir: ${libdir} includedir: ${includedir} + systemdunitdir: ${systemdsystemunitdir} compiler: ${CC} cflags: ${CFLAGS} diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am index ae3d894..6ee4726 100644 --- a/ndctl/Makefile.am +++ b/ndctl/Makefile.am @@ -47,3 +47,7 @@ monitor_config_file = monitor.conf monitor_configdir = /etc/ndctl/ monitor_config_DATA = $(monitor_config_file) EXTRA_DIST += $(monitor_config_file) + +if HAVE_SYSTEMD +systemdsystemunit_DATA = ndctl-monitor.service +endif diff --git a/ndctl/ndctl-monitor.service b/ndctl/ndctl-monitor.service new file mode 100644 index 0000000..44f9326 --- /dev/null +++ b/ndctl/ndctl-monitor.service @@ -0,0 +1,7 @@ +[Unit] +Description=Ndctl Monitor Daemon + +[Service] +Type=forking +ExecStart=/usr/bin/ndctl monitor --daemon +ExecStop=/bin/kill ${MAINPID}