Skip to contentSkip to conversation

multipath: systemd unit file

PATCH In review Benjamin Marzinski 3 participants 6 messages Sep 1, 2011

Subsystems (2)
lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

PATCH 1/1 multipath: systemd unit file

Here is a systemd unit file for managing multipathd.

---
 Makefile.inc                  |    1 +
 multipathd/Makefile           |    3 +++
 multipathd/multipathd.service |   14 ++++++++++++++
 3 files changed, 18 insertions(+)
Makefile.inc +1 -0
Index: multipath-tools-110831/Makefile.inc
===================================================================
@@ -31,6 +31,7 @@ man5dir     = $(prefix)/usr/share/man/ma
 rcdir	    = $(prefix)/etc/init.d
 syslibdir   = $(prefix)/$(LIB)
 libdir	    = $(prefix)/$(LIB)/multipath
+unitdir     = $(prefix)/lib/systemd/system
 
 GZIP        = /bin/gzip -9 -c
 INSTALL_PROGRAM = install
multipathd/Makefile +3 -0
Index: multipath-tools-110831/multipathd/Makefile
===================================================================
@@ -35,6 +35,8 @@ install:
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
 	$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(rcdir)
+	$(INSTALL_PROGRAM) -d $(DESTDIR)$(unitdir)
+	$(INSTALL_PROGRAM) -m 644 $(EXEC).service $(DESTDIR)$(unitdir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
 
@@ -42,6 +44,7 @@ uninstall:
 	rm -f $(DESTDIR)$(bindir)/$(EXEC)
 	rm -f $(DESTDIR)$(rcdir)/$(EXEC)
 	rm -f $(DESTDIR)$(mandir)/$(EXEC).8.gz
+	rm -f $(DESTDIR)$(unitdir)/$(EXEC).service
 
 clean:
 	rm -f core *.o $(EXEC) *.gz
multipathd/multipathd.service new file +14 -0
Index: multipath-tools-110831/multipathd/multipathd.service
===================================================================
@@ -0,0 +1,14 @@
+[Unit]
+Description=Device-Mapper Multipath Device Controller
+Before=iscsi.service iscsid.service
+After=syslog.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/multipathd.pid
+ExecStart=/sbin/multipathd
+ExecReload=/bin/kill -HUP $MAINPID
+#ExecStop=/path/to/scrip delete-me if not necessary
+
+[Install]
+WantedBy=multi-user.target
#1 lore raw
Quoted 2 lines · Benjamin Marzinski

Here is a systemd unit file for managing multipathd.

[ .. ]

Quoted 10 lines

Index: multipath-tools-110831/multipathd/multipathd.service
===================================================================

multipathd/multipathd.service new file +4 -0
@@ -0,0 +1,14 @@
+[Unit]
+Description=Device-Mapper Multipath Device Controller
+Before=iscsi.service iscsid.service
+After=syslog.target

multipathd/multipathd.service line 14

Quoted 10 lines
multipathd/multipathd.service new file +10 -0
+
+[Service]
+Type=forking
+PIDFile=/var/run/multipathd.pid
+ExecStart=/sbin/multipathd
+ExecReload=/bin/kill -HUP $MAINPID
+#ExecStop=/path/to/scrip delete-me if not necessary
+
+[Install]
+WantedBy=multi-user.target

Hmm. First of all, I'm trying to get rid of the PID file, as with it it's quite hard to start multipathing when /var/run isn't mounted. Plus it's not actually needed; everything can be done via multipathd -k nowadays.

So may I suggest to use
ExecReload=/sbin/multipathd -k'reconfigure'

here?
And do we actually need
PIDFile=
for systemd?
If not I'd rather remove that line, too.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
#2 lore raw
Quoted 11 lines
Quoted 11 lines

+[Unit]

multipathd/multipathd.service new file +10 -0
+Description=Device-Mapper Multipath Device Controller
+Before=iscsi.service iscsid.service
+After=syslog.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/multipathd.pid
+ExecStart=/sbin/multipathd
+ExecReload=/bin/kill -HUP $MAINPID
+#ExecStop=/path/to/scrip delete-me if not necessary
Quoted 9 lines

multipathd/multipathd.service line 14

Quoted 4 lines
multipathd/multipathd.service new file +3 -0
+
+[Install]
+WantedBy=multi-user.target

Hmm. First of all, I'm trying to get rid of the PID file, as with it it's quite hard to start multipathing when /var/run isn't mounted. Plus it's not actually needed; everything can be done via multipathd -k nowadays.

Agreed

Quoted 3 lines

So may I suggest to use
ExecReload=/sbin/multipathd -k'reconfigure'

Or even:
ExecReload=multipathd reconfigure

Regards,

Signature · 3 lines
Christophe Varoqui
OpenSVC - Tools to scale
http://www.opensvc.com/
#3 lore raw
Quoted 20 lines · Christophe Varoqui
Quoted 11 lines
Quoted 11 lines

+[Unit]

multipathd/multipathd.service new file +10 -0
+Description=Device-Mapper Multipath Device Controller
+Before=iscsi.service iscsid.service
+After=syslog.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/multipathd.pid
+ExecStart=/sbin/multipathd
+ExecReload=/bin/kill -HUP $MAINPID
+#ExecStop=/path/to/scrip delete-me if not necessary
Quoted 9 lines

multipathd/multipathd.service line 14

Quoted 4 lines
multipathd/multipathd.service new file +3 -0
+
+[Install]
+WantedBy=multi-user.target

Hmm. First of all, I'm trying to get rid of the PID file, as with it it's quite hard to start multipathing when /var/run isn't mounted. Plus it's not actually needed; everything can be done via multipathd -k nowadays.

Quoted 8 lines

Agreed

Quoted 3 lines

So may I suggest to use
ExecReload=/sbin/multipathd -k'reconfigure'

Or even:
ExecReload=multipathd reconfigure

That works? Cool.

Bet it's not documented in the manpage ...

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
author maintainer
#4 lore raw
In reply to Christophe Varoqui

Here is a systemd unit file for managing multipathd.

---
 Makefile.inc                  |    1 +
 multipathd/Makefile           |    3 +++
 multipathd/multipathd.service |   14 ++++++++++++++
 3 files changed, 18 insertions(+)
Makefile.inc +1 -0
Index: multipath-tools-110831/Makefile.inc
===================================================================
@@ -31,6 +31,7 @@ man5dir     = $(prefix)/usr/share/man/ma
 rcdir	    = $(prefix)/etc/init.d
 syslibdir   = $(prefix)/$(LIB)
 libdir	    = $(prefix)/$(LIB)/multipath
+unitdir     = $(prefix)/lib/systemd/system
 
 GZIP        = /bin/gzip -9 -c
 INSTALL_PROGRAM = install
multipathd/Makefile +3 -0
Index: multipath-tools-110831/multipathd/Makefile
===================================================================
@@ -35,6 +35,8 @@ install:
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
 	$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(rcdir)
+	$(INSTALL_PROGRAM) -d $(DESTDIR)$(unitdir)
+	$(INSTALL_PROGRAM) -m 644 $(EXEC).service $(DESTDIR)$(unitdir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
 
@@ -42,6 +44,7 @@ uninstall:
 	rm -f $(DESTDIR)$(bindir)/$(EXEC)
 	rm -f $(DESTDIR)$(rcdir)/$(EXEC)
 	rm -f $(DESTDIR)$(mandir)/$(EXEC).8.gz
+	rm -f $(DESTDIR)$(unitdir)/$(EXEC).service
 
 clean:
 	rm -f core *.o $(EXEC) *.gz
multipathd/multipathd.service new file +14 -0
Index: multipath-tools-110831/multipathd/multipathd.service
===================================================================
@@ -0,0 +1,14 @@
+[Unit]
+Description=Device-Mapper Multipath Device Controller
+Before=iscsi.service iscsid.service
+After=syslog.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/multipathd.pid
+ExecStart=/sbin/multipathd
+ExecReload=/sbin/multipathd reconfigure
+#ExecStop=/path/to/scrip delete-me if not necessary
+
+[Install]
+WantedBy=multi-user.target
author maintainer
#5 lore raw
In reply to Hannes Reinecke
Quoted 20 lines · Hannes Reinecke
Quoted 2 lines · Benjamin Marzinski

Here is a systemd unit file for managing multipathd.

[ .. ]

Quoted 16 lines

Index: multipath-tools-110831/multipathd/multipathd.service
===================================================================

multipathd/multipathd.service new file +11 -0
@@ -0,0 +1,14 @@
+[Unit]
+Description=Device-Mapper Multipath Device Controller
+Before=iscsi.service iscsid.service
+After=syslog.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/multipathd.pid
+ExecStart=/sbin/multipathd
+ExecReload=/bin/kill -HUP $MAINPID
+#ExecStop=/path/to/scrip delete-me if not necessary
Quoted 8 lines

multipathd/multipathd.service line 14

Quoted 4 lines
multipathd/multipathd.service new file +3 -0
+
+[Install]
+WantedBy=multi-user.target

Hmm. First of all, I'm trying to get rid of the PID file, as with it it's quite hard to start multipathing when /var/run isn't mounted. Plus it's not actually needed; everything can be done via multipathd -k nowadays.

At least on fedora, The systemd people changed /var/run so that it's now just a symlink to /run, which is a tmpfs filesystem.

Quoted 3 lines

So may I suggest to use
ExecReload=/sbin/multipathd -k'reconfigure'

Makes sense. Sure.

Quoted 5 lines

here?
And do we actually need
PIDFile=
for systemd?
If not I'd rather remove that line, too.

To comply with the Systemd Daemon best practices (in man systemd.service(5)), I appears so. But I don't believe that it's strictly necessary. If you don't add it, systemd will try to guess the mainpid, and since multipath multi-thread instead of multi-process, I'm pretty sure it will guess correctly.

But if /var/run becomes a tmpfs, then I don't see a need to remove the pidfile.

-Ben

Quoted 13 lines

Cheers,

Hannes

Signature · 9 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel