[pve-devel] [PATCH] cephserver : add systemd support V3

Alexandre Derumier aderumier at odiso.com
Wed May 18 01:52:59 CEST 2016


V3 changelog:
 -fix test of zero value id

 please note that even if ceph(osd|mon).target are currently not available in ceph packages,
 they are not used by proxmox api currently, because we always specify an id to a service.
 targets are used to start/stop all services at the same time. Starting speficic serviceid is
 done through ceph-(osd|mon)@.service files.

V2 changelog :
  - remove setsid
  - use [A-Za-z0-9]{1,32} pattern for services

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/CephTools.pm | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/PVE/CephTools.pm b/PVE/CephTools.pm
index ec91f44..c7749bb 100644
--- a/PVE/CephTools.pm
+++ b/PVE/CephTools.pm
@@ -191,9 +191,23 @@ sub setup_pve_symlinks {
 }
 
 sub ceph_service_cmd {
-    # ceph daemons does not call 'setsid', so we do that ourself
-    # (fork_worker send KILL to whole process group) 
-    PVE::Tools::run_command(['setsid', 'service', 'ceph', '-c', $pve_ceph_cfgpath, @_]);
+    my ($action, $service) = @_;
+
+    if(-f "/lib/systemd/system/ceph-osd at .service") {
+
+	if ($service && $service =~ m/^(mon|osd|mds|radosgw)(\.([A-Za-z0-9]{1,32}))?$/) {
+	    $service = defined($3) ? "ceph-$1\@$3" : "ceph-$1.target";
+	} else {
+	    $service = "ceph.target";
+	}
+
+	PVE::Tools::run_command(['/bin/systemctl', $action, $service]);
+
+    } else {
+	# ceph daemons does not call 'setsid', so we do that ourself
+	# (fork_worker send KILL to whole process group) 
+	PVE::Tools::run_command(['setsid', 'service', 'ceph', '-c', $pve_ceph_cfgpath, $action, $service]);
+    }
 }
 
 sub list_disks {
-- 
2.1.4




More information about the pve-devel mailing list