Ubuntu Pastebin

Paste from roaksoax at Wed, 27 May 2015 13:47:32 +0000

Download as text
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
=== modified file 'debian/control'
--- debian/control	2015-04-15 16:48:02 +0000
+++ debian/control	2015-05-11 09:59:09 +0000
@@ -49,7 +49,6 @@
 Architecture: all
 Depends: apache2,
          bind9utils,
-         daemontools,
          dbconfig-common,
          iproute,
          libjs-angularjs,

=== added file 'debian/maas-region-controller-min.maas-regiond-worker.upstart'
--- debian/maas-region-controller-min.maas-regiond-worker.upstart	1970-01-01 00:00:00 +0000
+++ debian/maas-region-controller-min.maas-regiond-worker.upstart	2015-05-11 09:59:09 +0000
@@ -0,0 +1,25 @@
+description "MAAS Region Controller (Worker)"
+author "Gavin Panella <gavin.panella@canonical.com>"
+
+# This instance job is started by the parent `maas-regiond` job, and
+# stops when that job is stopped. This is differentiated from its
+# siblings by the $core instance argument.
+
+instance $core
+
+stop on stopping maas-regiond
+
+setuid maas
+setgid maas
+
+respawn
+
+kill timeout 15
+
+env DJANGO_SETTINGS_MODULE=maas.settings
+env PYTHONPATH=/usr/share/maas
+env LOGFILE=/var/log/maas/regiond.log
+
+script
+    exec /usr/bin/twistd --nodaemon --pidfile= maas-regiond >> ${LOGFILE} 2>&1
+end script

=== modified file 'debian/maas-region-controller-min.maas-regiond.upstart'
--- debian/maas-region-controller-min.maas-regiond.upstart	2015-04-15 21:47:48 +0000
+++ debian/maas-region-controller-min.maas-regiond.upstart	2015-05-14 13:16:01 +0000
@@ -1,87 +1,17 @@
 description "MAAS Region Controller"
 author "Gavin Panella <gavin.panella@canonical.com>"
 
+# This starts multiple instances of `maas-regiond-worker` and does
+# nothing else itself; there is no main script so this runs "forever".
+# By default, it launches four workers.
+
 start on filesystem and net-device-up
 stop on runlevel [016]
 
-env svcdir=/var/lib/maas/regiond
-
-setuid maas
-setgid maas
-
 respawn
 
-# Give `supervise` time to exit in post-stop. It's not clear that this
-# time applies to pre/post scripts, so this may be for naught.
-kill timeout 15
-
 pre-start script
-    set -eu
-    # Create the service directory.
-    mkdir -p "${svcdir}"
-    # Create a `run` script in the service directory.
-    svcrun="${svcdir}/run"
-    echo "#!/bin/sh" > "${svcrun}"
-    echo "exec >> /var/log/maas/regiond.log 2>&1" >> "${svcrun}"
-    echo "export PYTHONPATH=/usr/share/maas" >> "${svcrun}"
-    echo "export DJANGO_SETTINGS_MODULE=maas.settings" >> "${svcrun}"
-    echo "exec /usr/bin/twistd --nodaemon --pidfile= maas-regiond" >> "${svcrun}"
-    chmod a+x "${svcrun}"
-    # We're going to create between 2 and 5 daemons, depending on core count.
-    daemons="$(nproc)"
-    if [ "${daemons}" -lt 2 ]
-    then
-        daemons=2
-    elif [ "${daemons}" -gt 5 ]
-    then
-        daemons=5
-    fi
-    # Create the run directories and link to the shared `run` script.
-    for daemon in $(seq "${daemons}")
-    do
-        rundir="${svcdir}/${daemon}"
-        mkdir -p "${rundir}"
-        runfile="${rundir}/run"
-        ln -snf "${svcrun}" "${runfile}"
-    done
-end script
-
-script
-    # In the case where this service has been restarted, we may have
-    # running `supervise` daemons. Bring each service up.
-    find "${svcdir}" -name run -executable \
-        -execdir svok . \; -execdir svc -u . \;
-    # In the case where this service has been restarted, we may also
-    # have leftover `down` markers. To remove these, we remove the
-    # `supervise` directories.
-    find "${svcdir}" -name supervise -type d \
-        -not -execdir svok . \; -execdir rm -rf {} \;
-    # Exec the `svscan` daemon, as the meta-supervisor.
-    exec svscan "${svcdir}"
-end script
-
-pre-stop script
-    # Bring each service down. We must *not* exit the `supervise` daemon
-    # because `svscan` may then have time in which to respawn it before
-    # it's stopped.
-    find "${svcdir}" -name run -executable -execdir svok . \; \
-        -printf "Bringing %h down.\n" -execdir svc -d . \;
-end script
-
-post-stop script
-    set -eu
-    # Bring each service down (belt-n-braces) and quit supervise; it's
-    # safe to do so now because `svscan` is guaranteed to have stopped.
-    find "${svcdir}" -name run -executable -execdir svok . \; \
-        -printf "Bringing %h down.\n" -execdir svc -dx . \;
-    # For up to 10 seconds -- less than the `kill timeout` -- check if
-    # any supervise daemons are still running every 0.1 seconds.
-    for attempt in $(seq 100)
-    do
-        # If one or more `supervise` daemons are still running, sleep.
-        find "${svcdir}" -name run -execdir svok . \; -exec sleep 0.1 \; -quit
-    done
-    # Kill with fire any remaining supervise daemons.
-    find "${svcdir}" -name run -executable -execdir svok . \; \
-        -printf "Killing %h; timed-out.\n" -execdir svc -k . \;
+    for core in $(seq 4); do
+        start maas-regiond-worker core=${core}
+    done
 end script

=== modified file 'debian/rules'
--- debian/rules	2015-04-15 16:48:02 +0000
+++ debian/rules	2015-05-11 09:59:09 +0000
@@ -17,6 +17,8 @@
 	dh_systemd_enable --name maas-regiond
 	dh_installinit --name maas-regiond
 	dh_systemd_start --name maas-regiond
+	# maas-regiond-worker
+	dh_installinit --name maas-regiond-worker
 	# maas-dhcpd
 	dh_systemd_enable --name maas-dhcpd
 	dh_installinit --name maas-dhcpd
Download as text