Merge lp:~allenap/maas/packaging.regiond-per-core into lp:~maas-maintainers/maas/packaging

Proposed by Gavin Panella
Status: Merged
Approved by: Andres Rodriguez
Approved revision: 382
Merged at revision: 379
Proposed branch: lp:~allenap/maas/packaging.regiond-per-core
Merge into: lp:~maas-maintainers/maas/packaging
Diff against target: 140 lines (+4/-18)
3 files modified
debian/changelog (+3/-0)
debian/control (+1/-0)
debian/maas-region-controller-min.maas-regiond.upstart (+0/-18)
To merge this branch: bzr merge lp:~allenap/maas/packaging.regiond-per-core
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+256197@code.launchpad.net

Commit message

Start one regiond per CPU core.

To post a comment you must log in.
379. By Gavin Panella

Get the thing working using a sleep.

380. By Gavin Panella

Get it working with sleep, redux.

381. By Gavin Panella

Use daemontools to make things worse.

382. By Gavin Panella

-k, not -dx

Revision history for this message
Andres Rodriguez (andreserl) :
review: Needs Information
Revision history for this message
Gavin Panella (allenap) :
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Ok, then! Comment inline!

review: Needs Fixing
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Approving this, but comments need to be addressed in the coming betas.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-04-08 22:14:39 +0000
3+++ debian/changelog 2015-04-15 21:48:14 +0000
4@@ -6,6 +6,9 @@
5 [ Mike Pontillo ]
6 * Stop maas-clusterd in prerm so that database purge succeeds (LP: #1044559)
7
8+ [ Gavin Panella ]
9+ * Run one maas-regiond per CPU core.
10+
11 -- Andres Rodriguez <andreserl@ubuntu.com> Mon, 06 Apr 2015 11:00:00 -0400
12
13 maas (1.8.0~beta1+bzr3777-0ubuntu1) trusty; urgency=medium
14
15=== modified file 'debian/control'
16--- debian/control 2015-04-06 14:08:41 +0000
17+++ debian/control 2015-04-15 21:48:14 +0000
18@@ -49,6 +49,7 @@
19 Architecture: all
20 Depends: apache2,
21 bind9utils,
22+ daemontools,
23 dbconfig-common,
24 iproute,
25 libjs-angularjs,
26
27=== added file 'debian/maas-region-controller-min.maas-regiond.upstart'
28--- debian/maas-region-controller-min.maas-regiond.upstart 1970-01-01 00:00:00 +0000
29+++ debian/maas-region-controller-min.maas-regiond.upstart 2015-04-15 21:48:14 +0000
30@@ -0,0 +1,87 @@
31+description "MAAS Region Controller"
32+author "Gavin Panella <gavin.panella@canonical.com>"
33+
34+start on filesystem and net-device-up
35+stop on runlevel [016]
36+
37+env svcdir=/var/lib/maas/regiond
38+
39+setuid maas
40+setgid maas
41+
42+respawn
43+
44+# Give `supervise` time to exit in post-stop. It's not clear that this
45+# time applies to pre/post scripts, so this may be for naught.
46+kill timeout 15
47+
48+pre-start script
49+ set -eu
50+ # Create the service directory.
51+ mkdir -p "${svcdir}"
52+ # Create a `run` script in the service directory.
53+ svcrun="${svcdir}/run"
54+ echo "#!/bin/sh" > "${svcrun}"
55+ echo "exec >> /var/log/maas/regiond.log 2>&1" >> "${svcrun}"
56+ echo "export PYTHONPATH=/usr/share/maas" >> "${svcrun}"
57+ echo "export DJANGO_SETTINGS_MODULE=maas.settings" >> "${svcrun}"
58+ echo "exec /usr/bin/twistd --nodaemon --pidfile= maas-regiond" >> "${svcrun}"
59+ chmod a+x "${svcrun}"
60+ # We're going to create between 2 and 5 daemons, depending on core count.
61+ daemons="$(nproc)"
62+ if [ "${daemons}" -lt 2 ]
63+ then
64+ daemons=2
65+ elif [ "${daemons}" -gt 5 ]
66+ then
67+ daemons=5
68+ fi
69+ # Create the run directories and link to the shared `run` script.
70+ for daemon in $(seq "${daemons}")
71+ do
72+ rundir="${svcdir}/${daemon}"
73+ mkdir -p "${rundir}"
74+ runfile="${rundir}/run"
75+ ln -snf "${svcrun}" "${runfile}"
76+ done
77+end script
78+
79+script
80+ # In the case where this service has been restarted, we may have
81+ # running `supervise` daemons. Bring each service up.
82+ find "${svcdir}" -name run -executable \
83+ -execdir svok . \; -execdir svc -u . \;
84+ # In the case where this service has been restarted, we may also
85+ # have leftover `down` markers. To remove these, we remove the
86+ # `supervise` directories.
87+ find "${svcdir}" -name supervise -type d \
88+ -not -execdir svok . \; -execdir rm -rf {} \;
89+ # Exec the `svscan` daemon, as the meta-supervisor.
90+ exec svscan "${svcdir}"
91+end script
92+
93+pre-stop script
94+ # Bring each service down. We must *not* exit the `supervise` daemon
95+ # because `svscan` may then have time in which to respawn it before
96+ # it's stopped.
97+ find "${svcdir}" -name run -executable -execdir svok . \; \
98+ -printf "Bringing %h down.\n" -execdir svc -d . \;
99+end script
100+
101+post-stop script
102+ set -eu
103+ # Bring each service down (belt-n-braces) and quit supervise; it's
104+ # safe to do so now because `svscan` is guaranteed to have stopped.
105+ find "${svcdir}" -name run -executable -execdir svok . \; \
106+ -printf "Bringing %h down.\n" -execdir svc -dx . \;
107+ # For up to 10 seconds -- less than the `kill timeout` -- check if
108+ # any supervise daemons are still running every 0.1 seconds.
109+ for attempt in $(seq 100)
110+ do
111+ # If one or more `supervise` daemons are still running, sleep.
112+ find "${svcdir}" -name run -execdir svok . \; -exec sleep 0.1 \; -quit
113+ done
114+ # Kill with fire any remaining supervise daemons.
115+ find "${svcdir}" -name run -executable -execdir svok . \; \
116+ -printf "Killing %h; timed-out.\n" -execdir svc -k . \;
117+end script
118
119=== removed file 'debian/maas-region-controller-min.maas-regiond.upstart'
120--- debian/maas-region-controller-min.maas-regiond.upstart 2015-01-22 09:28:01 +0000
121+++ debian/maas-region-controller-min.maas-regiond.upstart 1970-01-01 00:00:00 +0000
122@@ -1,18 +0,0 @@
123-description "MAAS Region Controller"
124-author "Gavin Panella <gavin.panella@canonical.com>"
125-
126-start on filesystem and net-device-up
127-stop on runlevel [016]
128-
129-setuid maas
130-setgid maas
131-
132-respawn
133-
134-env DJANGO_SETTINGS_MODULE=maas.settings
135-env PYTHONPATH=/usr/share/maas
136-env LOGFILE=/var/log/maas/regiond.log
137-
138-script
139- exec /usr/bin/twistd --nodaemon --pidfile= maas-regiond > ${LOGFILE} 2>&1
140-end script

Subscribers

People subscribed via source and target branches