Sha256: e5d5519c5696c8d4d0c5ff4835d513de428e4d30d9d716a7d639c4bbcdb76fe0

Contents?: true

Size: 1.46 KB

Versions: 7

Compression:

Stored size: 1.46 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

  echo "updating image bexio/amb:latest..."
  docker pull "bexio/amb:latest"

  mkdir -p /run/docker/upstart-service-containers
  run_id=\$(docker-utils make-ref 5)
  echo "${service_name}-i\${run_id}" > '/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" \
    amb:start '${remote_host}' '${remote_port}'
  )

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

echo "defined."

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
docker-utils-0.1.9 ./share/scripts/define-ambassador-service
docker-utils-0.1.8 ./share/scripts/define-ambassador-service
docker-utils-0.1.7 ./share/scripts/define-ambassador-service
docker-utils-0.1.6 ./share/scripts/define-ambassador-service
docker-utils-0.1.5 ./share/scripts/define-ambassador-service
docker-utils-0.1.4 ./share/scripts/define-ambassador-service
docker-utils-0.1.3 ./share/scripts/define-ambassador-service