summaryrefslogtreecommitdiff
path: root/src/upstart
diff options
context:
space:
mode:
authorTommi Virtanen <tv@inktank.com>2012-05-07 12:12:48 -0700
committerTommi Virtanen <tv@inktank.com>2012-05-23 14:02:34 -0700
commit176a14aef90e7ed0a241f48e5c6667ff1c100e50 (patch)
treeb4e2809cba11892ce1bb50676b76c39112674d59 /src/upstart
parent475e07a256410e7ab4201ac5ad78cc35f61e6a2f (diff)
downloadceph-176a14aef90e7ed0a241f48e5c6667ff1c100e50.tar.gz
debian, upstart, osd: osd disk preparation and activation scripts
Signed-off-by: Tommi Virtanen <tv@inktank.com>
Diffstat (limited to 'src/upstart')
-rw-r--r--src/upstart/ceph-hotplug.conf10
-rw-r--r--src/upstart/ceph-mon-all.conf26
-rw-r--r--src/upstart/ceph-mon.conf18
-rw-r--r--src/upstart/ceph-osd.conf28
4 files changed, 82 insertions, 0 deletions
diff --git a/src/upstart/ceph-hotplug.conf b/src/upstart/ceph-hotplug.conf
new file mode 100644
index 00000000000..817f34120ec
--- /dev/null
+++ b/src/upstart/ceph-hotplug.conf
@@ -0,0 +1,10 @@
+description "Ceph hotplug"
+
+start on block-device-added \
+ DEVTYPE=partition \
+ ID_PART_ENTRY_TYPE=4fbd7e29-9d25-41b8-afd0-062c0ceff05d
+
+task
+instance $DEVNAME
+
+exec /usr/sbin/ceph-disk-activate --mount -- "$DEVNAME"
diff --git a/src/upstart/ceph-mon-all.conf b/src/upstart/ceph-mon-all.conf
new file mode 100644
index 00000000000..749417d71ba
--- /dev/null
+++ b/src/upstart/ceph-mon-all.conf
@@ -0,0 +1,26 @@
+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
diff --git a/src/upstart/ceph-mon.conf b/src/upstart/ceph-mon.conf
new file mode 100644
index 00000000000..24ae88a2709
--- /dev/null
+++ b/src/upstart/ceph-mon.conf
@@ -0,0 +1,18 @@
+description "Ceph MON"
+
+stop on runlevel [!2345]
+
+respawn
+respawn limit 5 30
+
+pre-start script
+ set -e
+ test -x /usr/bin/ceph-mon || { stop; exit 0; }
+ test -d "/var/lib/ceph/mon/${cluster:-ceph}-$id" || { stop; exit 0; }
+
+ install -d -m0755 /var/run/ceph
+end script
+
+instance ${cluster:-ceph}/$id
+
+exec /usr/bin/ceph-mon --cluster="${cluster:-ceph}" -i "$id" -f
diff --git a/src/upstart/ceph-osd.conf b/src/upstart/ceph-osd.conf
new file mode 100644
index 00000000000..1b4c950bea1
--- /dev/null
+++ b/src/upstart/ceph-osd.conf
@@ -0,0 +1,28 @@
+description "Ceph OSD"
+
+stop on runlevel [!2345]
+
+respawn
+respawn limit 5 30
+
+pre-start script
+ set -e
+ test -x /usr/bin/ceph-osd || { stop; exit 0; }
+ test -d "/var/lib/ceph/osd/${cluster:-ceph}-$id" || { stop; exit 0; }
+
+ install -d -m0755 /var/run/ceph
+
+ # update location in crush
+ # TODO: un-hardcode the domain=root assumption
+ ceph \
+ --cluster="${cluster:-ceph}" \
+ --name="osd.$id" \
+ --keyring="/var/lib/ceph/osd/${cluster:-ceph}-$id/keyring" \
+ osd crush set \
+ "$id" "osd.$id" 1 domain=root \
+ || :
+end script
+
+instance ${cluster:-ceph}/$id
+
+exec /usr/bin/ceph-osd --cluster="${cluster:-ceph}" -i "$id" -f