mirror of https://github.com/docker/docs.git
Make scale timeout configurable, default to 10
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
ca298309e0
commit
9d0bbdf8dd
|
@ -372,8 +372,14 @@ class TopLevelCommand(Command):
|
||||||
|
|
||||||
$ docker-compose scale web=2 worker=3
|
$ docker-compose scale web=2 worker=3
|
||||||
|
|
||||||
Usage: scale [SERVICE=NUM...]
|
Usage: scale [options] [SERVICE=NUM...]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-t, --timeout TIMEOUT Specify a shutdown timeout in seconds.
|
||||||
|
(default: 10)
|
||||||
"""
|
"""
|
||||||
|
timeout = int(options.get('--timeout') or DEFAULT_TIMEOUT)
|
||||||
|
|
||||||
for s in options['SERVICE=NUM']:
|
for s in options['SERVICE=NUM']:
|
||||||
if '=' not in s:
|
if '=' not in s:
|
||||||
raise UserError('Arguments to scale should be in the form service=num')
|
raise UserError('Arguments to scale should be in the form service=num')
|
||||||
|
@ -383,7 +389,7 @@ class TopLevelCommand(Command):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise UserError('Number of containers for service "%s" is not a '
|
raise UserError('Number of containers for service "%s" is not a '
|
||||||
'number' % service_name)
|
'number' % service_name)
|
||||||
project.get_service(service_name).scale(num)
|
project.get_service(service_name).scale(num, timeout=timeout)
|
||||||
|
|
||||||
def start(self, project, options):
|
def start(self, project, options):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -147,7 +147,7 @@ class Service(object):
|
||||||
|
|
||||||
# end TODO
|
# end TODO
|
||||||
|
|
||||||
def scale(self, desired_num):
|
def scale(self, desired_num, timeout=DEFAULT_TIMEOUT):
|
||||||
"""
|
"""
|
||||||
Adjusts the number of containers to the specified number and ensures
|
Adjusts the number of containers to the specified number and ensures
|
||||||
they are running.
|
they are running.
|
||||||
|
@ -181,7 +181,7 @@ class Service(object):
|
||||||
while len(running_containers) > desired_num:
|
while len(running_containers) > desired_num:
|
||||||
c = running_containers.pop()
|
c = running_containers.pop()
|
||||||
log.info("Stopping %s..." % c.name)
|
log.info("Stopping %s..." % c.name)
|
||||||
c.stop(timeout=1)
|
c.stop(timeout=timeout)
|
||||||
stopped_containers.append(c)
|
stopped_containers.append(c)
|
||||||
|
|
||||||
# Start containers
|
# Start containers
|
||||||
|
|
Loading…
Reference in New Issue