From 3764ca6115fe7c0bf8dcba448af012625ea5abc3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 2 Jun 2012 15:19:28 -0700 Subject: [PATCH] upstart: simplify start; allow group stop via an abstract job Use a 'ceph-mds' or 'ceph-mon' event to start instances instead of explicitly calling start. This avoids the ugly is-this-already-running check. [Thanks Guilhem Lettron for that!] Make the -all job abstract (which means it stays started and can be stopped). Trigger a helper task (-all-starter) to trigger instance start. Make instances stop with the -all task. This allows you to do start ceph-mds-all stop ceph-mds-all start ceph-mds id=foo start ceph-mds-all stop ceph-mds id=bar stop ceph-mds-all but not start ceph-mds id=foo stop ceph-mds-all because ceph-mds-all isn't running. Not quite as flexible in sysvinit in that regard, but good enough for me. Fixes: #2414 Signed-off-by: Sage Weil --- src/Makefile.am | 6 ++++-- src/upstart/ceph-mds-all-starter.conf | 18 ++++++++++++++++++ src/upstart/ceph-mds-all.conf | 27 +-------------------------- src/upstart/ceph-mds.conf | 6 +++++- src/upstart/ceph-mon-all-starter.conf | 19 +++++++++++++++++++ src/upstart/ceph-mon-all.conf | 27 +-------------------------- src/upstart/ceph-mon.conf | 6 +++++- 7 files changed, 53 insertions(+), 56 deletions(-) create mode 100644 src/upstart/ceph-mds-all-starter.conf create mode 100644 src/upstart/ceph-mon-all-starter.conf diff --git a/src/Makefile.am b/src/Makefile.am index abd0e6b7e062c..977807194aa95 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -885,12 +885,14 @@ EXTRA_DIST += \ $(ceph_tool_gui_DATA) \ $(srcdir)/test/encoding/readable.sh \ $(srcdir)/test/encoding/check-generated.sh \ - $(srcdir)/upstart/ceph-mon-all.conf \ $(srcdir)/upstart/ceph-mon.conf \ + $(srcdir)/upstart/ceph-mon-all.conf \ + $(srcdir)/upstart/ceph-mon-all-starter.conf \ $(srcdir)/upstart/ceph-osd.conf \ $(srcdir)/upstart/ceph-hotplug.conf \ - $(srcdir)/upstart/ceph-mds-all.conf \ $(srcdir)/upstart/ceph-mds.conf \ + $(srcdir)/upstart/ceph-mds-all.conf \ + $(srcdir)/upstart/ceph-mds-all-starter.conf \ ceph-disk-prepare \ ceph-disk-activate diff --git a/src/upstart/ceph-mds-all-starter.conf b/src/upstart/ceph-mds-all-starter.conf new file mode 100644 index 0000000000000..4d4de6cdacebe --- /dev/null +++ b/src/upstart/ceph-mds-all-starter.conf @@ -0,0 +1,18 @@ +description "Ceph MDS (task to start all instances)" + +start on starting ceph-mds-all + +task + +script + set -e + # TODO what's the valid charset for cluster names and mds ids? + find /var/lib/ceph/mds/ -mindepth 1 -maxdepth 1 -regextype posix-egrep -regex '.*/[a-z0-9]+-[a-z0-9]+' -printf '%P\n' \ + | while read f; do + if [ -e "/var/lib/ceph/mds/$f/done" ]; then + cluster="${f%%-*}" + id="${f#*-}" + initctl emit ceph-mds cluster="$cluster" id="$id" + fi + done +end script diff --git a/src/upstart/ceph-mds-all.conf b/src/upstart/ceph-mds-all.conf index 776d31118c267..35c2e06e66403 100644 --- a/src/upstart/ceph-mds-all.conf +++ b/src/upstart/ceph-mds-all.conf @@ -1,26 +1 @@ -description "Ceph MDS (start all instances)" - -start on filesystem - -task - -script - set -e - # TODO what's the valid charset for cluster names and mds ids? - find /var/lib/ceph/mds/ -mindepth 1 -maxdepth 1 -regextype posix-egrep -regex '.*/[a-z0-9]+-[a-z0-9]+' -printf '%P\n' \ - | while read f; do - if [ -e "/var/lib/ceph/mds/$f/done" ]; then - cluster="${f%%-*}" - id="${f#*-}" - - # upstart start(8) fails if the job is already running - # https://bugs.launchpad.net/upstart/+bug/878322 - - # also cannot ask for status of instance that isn't running at - # that time, so just list all and filter that - if initctl list|mawk '$1=="ceph-mds" && $2=="(" CLUSTER "/" INSTANCE ")" && $3~/start\// { exit 1 }' CLUSTER="$cluster" INSTANCE="$id"; then - start ceph-mds cluster="$cluster" id="$id" - fi - fi - done -end script +description "Ceph MDS (all instances)" diff --git a/src/upstart/ceph-mds.conf b/src/upstart/ceph-mds.conf index 2438a975b07e7..56aa5bce6b520 100644 --- a/src/upstart/ceph-mds.conf +++ b/src/upstart/ceph-mds.conf @@ -1,6 +1,7 @@ description "Ceph MDS" -stop on runlevel [!2345] +start on ceph-mds +stop on runlevel [!2345] or stopping ceph-mds-all respawn respawn limit 5 30 @@ -15,4 +16,7 @@ end script instance ${cluster:-ceph}/$id +# this breaks oneiric +#usage "cluster = name of cluster (defaults to 'ceph'); id = mds instance id" + exec /usr/bin/ceph-mds --cluster="${cluster:-ceph}" -i "$id" -f diff --git a/src/upstart/ceph-mon-all-starter.conf b/src/upstart/ceph-mon-all-starter.conf new file mode 100644 index 0000000000000..bc3c4d41d8a52 --- /dev/null +++ b/src/upstart/ceph-mon-all-starter.conf @@ -0,0 +1,19 @@ +description "Ceph MON (start all instances)" + +start on starting ceph-mon-all + +task + +script + set -e + # TODO what's the valid charset for cluster names and mon ids? + find /var/lib/ceph/mon/ -mindepth 1 -maxdepth 1 -regextype posix-egrep -regex '.*/[a-z0-9]+-[a-z0-9]+' -printf '%P\n' \ + | while read f; do + if [ -e "/var/lib/ceph/mon/$f/done" ]; then + cluster="${f%%-*}" + id="${f#*-}" + + initctl emit ceph-mon cluster="$cluster" id="$id" + fi + done +end script diff --git a/src/upstart/ceph-mon-all.conf b/src/upstart/ceph-mon-all.conf index 749417d71ba37..391cc5984700b 100644 --- a/src/upstart/ceph-mon-all.conf +++ b/src/upstart/ceph-mon-all.conf @@ -1,26 +1 @@ -description "Ceph MON (start all instances)" - -start on filesystem - -task - -script - set -e - # TODO what's the valid charset for cluster names and mon ids? - find /var/lib/ceph/mon/ -mindepth 1 -maxdepth 1 -regextype posix-egrep -regex '.*/[a-z0-9]+-[a-z0-9]+' -printf '%P\n' \ - | while read f; do - if [ -e "/var/lib/ceph/mon/$f/done" ]; then - cluster="${f%%-*}" - id="${f#*-}" - - # upstart start(8) fails if the job is already running - # https://bugs.launchpad.net/upstart/+bug/878322 - - # also cannot ask for status of instance that isn't running at - # that time, so just list all and filter that - if initctl list|mawk '$1=="ceph-mon" && $2=="(" CLUSTER "/" INSTANCE ")" && $3~/start\// { exit 1 }' CLUSTER="$cluster" INSTANCE="$id"; then - start ceph-mon cluster="$cluster" id="$id" - fi - fi - done -end script +description "Ceph monitor (all instances)" diff --git a/src/upstart/ceph-mon.conf b/src/upstart/ceph-mon.conf index 24ae88a2709ae..b38eff309f02b 100644 --- a/src/upstart/ceph-mon.conf +++ b/src/upstart/ceph-mon.conf @@ -1,6 +1,7 @@ description "Ceph MON" -stop on runlevel [!2345] +start on ceph-mon +stop on runlevel [!2345] or stopping ceph-mon-all respawn respawn limit 5 30 @@ -15,4 +16,7 @@ end script instance ${cluster:-ceph}/$id +# this breaks oneiric +#usage "cluster = name of cluster (defaults to 'ceph'); id = monitor instance id" + exec /usr/bin/ceph-mon --cluster="${cluster:-ceph}" -i "$id" -f -- 2.39.5