Commit e8b721ce authored by BAIRE Anthony's avatar BAIRE Anthony
Browse files

restart the sandboxes if interrupted

(+ quote w/ shlex)
parent 1c3a00f6
......@@ -511,7 +511,7 @@ class SandboxManager(Manager):
# FIXME: do nothing if entrypoint already exists
command = ["/bin/sh", "-c", """
{mkdir}
cat > {entrypoint!r} <<EOF
test -f {entrypoint} || cat > {entrypoint} <<EOF
#!/bin/sh
echo
echo "This is app '{name}' called with parameters '\$@'"
......@@ -519,12 +519,12 @@ echo
echo "The workdir contains:"
ls -l
EOF
chmod 0755 -- {entrypoint!r}
chmod 0755 -- {entrypoint}
exec {cmd}
""".format( entrypoint = webapp.entrypoint,
""".format( entrypoint = shlex.quote(webapp.entrypoint),
name = webapp.docker_name,
mkdir = (("mkdir -p -- %r" % dn) if dn else ""),
cmd = " ".join(map(repr, command)))]
mkdir = (("mkdir -p -- %s" % shlex.quote(dn)) if dn else ""),
cmd = " ".join(map(shlex.quote, command)))]
ctrl.sandbox.create_container(image, name=container, hostname=container,
command = command,
......@@ -535,6 +535,7 @@ EOF
},
# TODO: maybe drop other caps
cap_drop = ["NET_RAW"],
restart_policy = {"Name": "unless-stopped"},
))
ctrl.sandbox.start(container)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment