Sha256: 41efd04d8136697822d0db2f4ace3486928e2c409aa583b8afc526079653fad7

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

#!/bin/bash

echo -n "defining ambassador service '$1'... "

service_name=$1; shift

remote_host=$1; shift
remote_port=$1; shift

if [ -n "$LOGENTRIES_ACCOUNT_KEY" ]; then
  touch "/var/log/upstart/${service_name}.log"
  le follow --name="${service_name}" "/var/log/upstart/${service_name}.log" 2>/dev/null 1>&2
  service logentries restart 2>/dev/null 1>&2
fi

cat >"/etc/init/${service_name}.conf" <<EOF
stop on stopping docker

env HOME=/root

respawn
respawn limit 5 20

pre-start script
  . /etc/environment.local

  mkdir -p /run/docker/upstart-service-containers
  run_id=\$(docker-utils make-ref 5)
  echo "${service_name}" > '/run/docker/upstart-service-containers/${service_name}'
end script

post-stop script
  container_name="\$(cat '/run/docker/upstart-service-containers/${service_name}')"
  docker stop "\${container_name}" || :
  docker rm "\${container_name}" || :
  rm '/run/docker/upstart-service-containers/${service_name}'
end script

script
  . /etc/environment.local

  container_name="\$(cat '/run/docker/upstart-service-containers/${service_name}')"

  echo "starting container: \${container_name} (from bexio/amb:latest)..."

  running_container_id=\$(docker run -d \
    --name="\${container_name}" \
    "bexio/amb:latest" \
    '${remote_host}' '${remote_port}'
  )

  exec docker attach --sig-proxy=true "\${running_container_id}" | logger -t "${service_name}"
end script
EOF

echo "defined."

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
docker-utils-0.1.19 ./share/scripts/define-ambassador-service
docker-utils-0.1.18 ./share/scripts/define-ambassador-service