From patchwork Fri Jun 29 02:30:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: QI Fuli X-Patchwork-Id: 10495549 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 0763660325 for ; Fri, 29 Jun 2018 02:31:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E73AE2A6B0 for ; Fri, 29 Jun 2018 02:31:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB8EA2A6E0; Fri, 29 Jun 2018 02:31:18 +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.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,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 94A1F2A6B0 for ; Fri, 29 Jun 2018 02:31:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8CE4F203369C1; Thu, 28 Jun 2018 19:31:18 -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=202.219.69.168; helo=mgwkm01.jp.fujitsu.com; envelope-from=qi.fuli@jp.fujitsu.com; receiver=linux-nvdimm@lists.01.org Received: from mgwkm01.jp.fujitsu.com (mgwkm01.jp.fujitsu.com [202.219.69.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0D479211F889C for ; Thu, 28 Jun 2018 19:31:16 -0700 (PDT) Received: from kw-mxauth.gw.nic.fujitsu.com (unknown [192.168.231.132]) by mgwkm01.jp.fujitsu.com with smtp id 292d_38ce_f6fd5cb5_488c_43b6_8c47_eeb79cf3d8b9; Fri, 29 Jun 2018 11:31:11 +0900 Received: from m3051.s.css.fujitsu.com (m3051.s.css.fujitsu.com [10.134.21.209]) by kw-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id 33AE1AC0308 for ; Fri, 29 Jun 2018 11:31:08 +0900 (JST) Received: from qi-fedora.fujitsu.com (unknown [10.124.196.110]) by m3051.s.css.fujitsu.com (Postfix) with ESMTP id 132CB3F5; Fri, 29 Jun 2018 11:31:08 +0900 (JST) From: QI Fuli To: linux-nvdimm@lists.01.org Subject: [PATCH v9 3/3] ndctl, monitor: add the unit file of systemd for ndctl-monitor service Date: Fri, 29 Jun 2018 11:30:50 +0900 Message-Id: <20180629023050.29217-4-qi.fuli@jp.fujitsu.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180629023050.29217-1-qi.fuli@jp.fujitsu.com> References: <20180629023050.29217-1-qi.fuli@jp.fujitsu.com> X-TM-AS-MML: disable 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: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP 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]". A monitor daemon can be started as a system service: # systemctl start ndctl-monitor.service 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 2a52688..21b0e25 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 cf44260..a5ba9a1 100644 --- a/configure.ac +++ b/configure.ac @@ -143,6 +143,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_unitdir], [$with_systemd_unit_dir])]) +AM_CONDITIONAL([ENABLE_SYSTEMD_UNIT_DIR], [test "x$with_systemd_unit_dir" != "xno"]) + my_CFLAGS="\ -Wall \ -Wchar-subscripts \ @@ -184,6 +205,7 @@ AC_MSG_RESULT([ sysconfdir: ${sysconfdir} libdir: ${libdir} includedir: ${includedir} + systemd-unit-dir: ${systemd_unitdir} compiler: ${CC} cflags: ${CFLAGS} diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am index ae3d894..9d008d5 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_unit_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}