Implement lxc-build HALT and fix some minor regressions
This commit is contained in:
parent
fc99f7f6ab
commit
00154ef899
@ -56,3 +56,4 @@ MOUNT DIR /srv/crisiscleanup/conf srv/crisiscleanup/config
|
||||
USER 8005 8005
|
||||
WORKDIR /srv/crisiscleanup
|
||||
CMD rails server
|
||||
HALT SIGTERM
|
||||
|
@ -26,10 +26,9 @@ cp ${SOURCE_DIR}/srv/crisiscleanup/conf/environments/production.rb /srv/crisiscl
|
||||
vmmgr update-login crisiscleanup "${CRISISCLEANUP_ADMIN_EMAIL}" "${CRISISCLEANUP_ADMIN_PWD}"
|
||||
|
||||
# Populate database
|
||||
envsubst <${SOURCE_DIR}/srv/crisiscleanup/db/seeds.rb >/var/lib/lxc/crisiscleanup/crisiscleanup/tmp/seeds.rb
|
||||
envsubst <${SOURCE_DIR}/srv/crisiscleanup/db/seeds.rb >/var/lib/lxc/crisiscleanup/crisiscleanup/srv/crisiscleanup/db/seeds.rb
|
||||
lxc-execute crisiscleanup -- rake db:schema:load
|
||||
lxc-execute crisiscleanup -- rake db:seed
|
||||
rm /var/lib/lxc/crisiscleanup/crisiscleanup/tmp/seeds.rb
|
||||
|
||||
# Install service
|
||||
cp ${SOURCE_DIR}/etc/init.d/crisiscleanup /etc/init.d/crisiscleanup
|
||||
|
@ -10,6 +10,7 @@ RUN EOF
|
||||
# Create OS user
|
||||
addgroup -S -g 8018 sms
|
||||
adduser -S -u 8018 -h /srv/frontlinesms -s /bin/sh -g sms -G sms sms
|
||||
adduser sms dialout
|
||||
|
||||
# Install FrontlineSMS
|
||||
wget http://download-frontlinesms.s3.amazonaws.com/frontlinesms2_unix_2.6.5.sh -O /tmp/frontlinesms2.sh
|
||||
|
3
openmapkit/lxc/etc/services.d/.s6-svscan/finish
Executable file
3
openmapkit/lxc/etc/services.d/.s6-svscan/finish
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
/bin/true
|
6
openmapkit/lxc/etc/services.d/openmapkit/run
Executable file
6
openmapkit/lxc/etc/services.d/openmapkit/run
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
export NODE_ENV production
|
||||
s6-setuidgid 8007:8007
|
||||
/usr/bin/node /srv/openmapkit/server.js
|
@ -36,10 +36,9 @@ RUN EOF
|
||||
rm -rf /root/.cache /root/.config /root/.node-gyp /root/.npm
|
||||
EOF
|
||||
|
||||
COPY lxc
|
||||
|
||||
MOUNT FILE /srv/openmapkit/conf/settings.js srv/openmapkit/settings.js
|
||||
MOUNT DIR /srv/openmapkit/data srv/openmapkit/data
|
||||
|
||||
USER 8007 8007
|
||||
ENV NODE_ENV production
|
||||
WORKDIR /srv/openmapkit
|
||||
CMD node server.js
|
||||
CMD s6-svscan /etc/services.d
|
||||
|
@ -93,5 +93,4 @@ EOF
|
||||
MOUNT DIR /srv/pandora/conf srv/pandora/conf
|
||||
MOUNT DIR /srv/pandora/data srv/pandora/data
|
||||
|
||||
WORKDIR /srv/pandora
|
||||
CMD s6-svscan /etc/services.d
|
||||
|
@ -34,7 +34,7 @@ lxc.environment = PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/
|
||||
{env}
|
||||
|
||||
# Halt
|
||||
lxc.signal.halt = SIGTERM
|
||||
lxc.signal.halt = {halt}
|
||||
|
||||
# Log
|
||||
lxc.console.size = 1MB
|
||||
@ -59,6 +59,7 @@ class LXCImage:
|
||||
self.gid = 0
|
||||
self.cmd = '/bin/true'
|
||||
self.cwd = '/'
|
||||
self.halt = 'SIGINT'
|
||||
|
||||
if os.path.isfile(build_path):
|
||||
self.lxcfile = os.path.realpath(build_path)
|
||||
@ -106,6 +107,8 @@ class LXCImage:
|
||||
self.set_cmd(' '.join(line.split()[1:]))
|
||||
elif line.startswith('WORKDIR'):
|
||||
self.set_cwd(line.split()[1])
|
||||
elif line.startswith('HALT'):
|
||||
self.set_halt(line.split()[1])
|
||||
# Add the final layer which can be treated as ephemeral
|
||||
self.add_layer('{}/delta0'.format(self.name))
|
||||
|
||||
@ -118,7 +121,10 @@ class LXCImage:
|
||||
mounts = '\n'.join(self.mounts)
|
||||
env = '\n'.join(self.env)
|
||||
with open(os.path.join(LXC_ROOT, self.name, 'config'), 'w') as fd:
|
||||
fd.write(CONFIG_TEMPLATE.format(name=self.name, rootfs=rootfs, mounts=mounts, env=env, uid=self.uid, gid=self.gid, cmd=self.cmd, cwd=self.cwd))
|
||||
fd.write(CONFIG_TEMPLATE.format(name=self.name,
|
||||
rootfs=rootfs, mounts=mounts, env=env,
|
||||
uid=self.uid, gid=self.gid,
|
||||
cmd=self.cmd, cwd=self.cwd, halt=self.halt))
|
||||
|
||||
def run_script(self, script):
|
||||
sh = os.path.join(self.layers[-1], 'run.sh')
|
||||
@ -167,6 +173,10 @@ class LXCImage:
|
||||
self.cwd = cwd
|
||||
self.rebuild_config()
|
||||
|
||||
def set_halt(self, cwd):
|
||||
self.halt = halt
|
||||
self.rebuild_config()
|
||||
|
||||
def copy_tree(src, dst):
|
||||
if not os.path.isdir(src):
|
||||
shutil.copy2(src, dst)
|
||||
|
Loading…
Reference in New Issue
Block a user