nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: "Qi, Fuli" <qi.fuli@jp.fujitsu.com>
To: 'Masayoshi Mizuma' <msys.mizuma@gmail.com>,
	"linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Subject: RE: [PATCH v5 4/4] ndctl, monitor: add the unit file of systemd for ndctl-monitor service
Date: Mon, 7 May 2018 01:47:15 +0000	[thread overview]
Message-ID: <0DEDF3B159719A448A49EF0E7B11E3222766040C@g01jpexmbkw01> (raw)
In-Reply-To: <4ee59ab2-7c2f-1444-5e27-fda231982b0d@gmail.com>

> -----Original Message-----
> From: Masayoshi Mizuma [mailto:msys.mizuma@gmail.com]
> Sent: Wednesday, May 2, 2018 12:07 AM
> To: Qi, Fuli/斉 福利 <qi.fuli@jp.fujitsu.com>; linux-nvdimm@lists.01.org
> Subject: Re: [PATCH v5 4/4] ndctl, monitor: add the unit file of systemd for
> ndctl-monitor service
> 
> 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 <qi.fuli@jp.fujitsu.com>
> >
> > ---
> >  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?

Thank you for your comments.
Yes, this is a bug.
I will make a new version and fix 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?
> 

I did try to use the autoconf systemd example code, but I found the indent of generated code in configure was difficult to read.
Therefore, I didn’t use "AS_IF" macro.
Moreover, the values "auto" and "yes" have the same meaning in this case, I deleted "auto" and make the code easy to read.
Also, imitating the other items in configure.ac like "ENABLE_BASH_COMPLETION", I changed the conditional "HAVE_SYSTEMD" to "ENABLE_SYSTEMD_UNIT_DIR".

> ---
>  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}
> --
> 1.8.3.1
> 
> - Masa

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

      reply	other threads:[~2018-05-07  1:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-26 11:30 [PATCH v5 0/4] ndctl, monitor: add ndctl monitor daemon QI Fuli
2018-04-26 11:30 ` [PATCH v5 1/4] ndctl, util: add OPTION_FILENAME to parse_opt_type QI Fuli
2018-05-04  3:25   ` Dan Williams
2018-05-07  1:50     ` Qi, Fuli
2018-04-26 11:30 ` [PATCH v5 2/4] ndctl, monitor: add ndctl monitor daemon QI Fuli
2018-04-26 11:30 ` [PATCH v5 3/4] ndctl, monitor: add default configuration file QI Fuli
2018-04-26 11:30 ` [PATCH v5 4/4] ndctl, monitor: add the unit file of systemd for ndctl-monitor service QI Fuli
2018-05-01 15:07   ` Masayoshi Mizuma
2018-05-07  1:47     ` Qi, Fuli [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0DEDF3B159719A448A49EF0E7B11E3222766040C@g01jpexmbkw01 \
    --to=qi.fuli@jp.fujitsu.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=msys.mizuma@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).