Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
feat(controller/coreos.py) Adding TimeoutStartSec to log and announce…
Browse files Browse the repository at this point in the history
… services

Sometimes log and announce services fail to start because they depend
on the main service, but if it takes too long they fail because of
timeout. This commit just adds the same timeout to log and announce
services than the main service has.
  • Loading branch information
softr8 committed Jul 14, 2014
1 parent fc906e7 commit 57078a4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions controller/scheduler/coreos.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def attach(self, name):
ExecStartPre=/bin/sh -c "until docker inspect -f '{{{{range $i, $e := .HostConfig.PortBindings }}}}{{{{$p := index $e 0}}}}{{{{$p.HostPort}}}}{{{{end}}}}' {name} >/dev/null 2>&1; do sleep 2; done; port=$(docker inspect -f '{{{{range $i, $e := .HostConfig.PortBindings }}}}{{{{$p := index $e 0}}}}{{{{$p.HostPort}}}}{{{{end}}}}' {name}); if [[ -z $port ]]; then echo We have no port...; exit 1; fi; echo Waiting for $port/tcp...; until netstat -lnt | grep :$port >/dev/null; do sleep 1; done"
ExecStart=/bin/sh -c "port=$(docker inspect -f '{{{{range $i, $e := .HostConfig.PortBindings }}}}{{{{$p := index $e 0}}}}{{{{$p.HostPort}}}}{{{{end}}}}' {name}); echo Connected to $COREOS_PRIVATE_IPV4:$port/tcp, publishing to etcd...; while netstat -lnt | grep :$port >/dev/null; do etcdctl set /deis/services/{app}/{name} $COREOS_PRIVATE_IPV4:$port --ttl 60 >/dev/null; sleep 45; done"
ExecStop=/usr/bin/etcdctl rm --recursive /deis/services/{app}/{name}
TimeoutStartSec=20m
[X-Fleet]
X-ConditionMachineOf={name}.service
Expand All @@ -252,6 +253,7 @@ def attach(self, name):
[Service]
ExecStartPre=/bin/sh -c "until docker inspect {name} >/dev/null 2>&1; do sleep 1; done"
ExecStart=/bin/sh -c "docker logs -f {name} 2>&1 | logger -p local0.info -t {app}[{c_type}.{c_num}] --udp --server $(etcdctl get /deis/logs/host | cut -d ':' -f1) --port $(etcdctl get /deis/logs/port | cut -d ':' -f2)"
TimeoutStartSec=20m
[X-Fleet]
X-ConditionMachineOf={name}.service
Expand Down

0 comments on commit 57078a4

Please sign in to comment.