From 4fcbeff22f30b57dc6d1b252cb5df49c4c2f3907 Mon Sep 17 00:00:00 2001 From: gholt Date: Mon, 17 Dec 2012 23:06:22 +0000 Subject: [PATCH] Added override for swift-init's KILL_WAIT You can now give swift-init a -k N (or --kill-wait N) option to override the default 15 second wait for a process to die after sending it the die signal. This is useful for boxes that are awfully slow for whatever reason. DocImpact Change-Id: I328ec254f6e0ee1cd423c1d062ba4c5331bd8337 --- bin/swift-init | 6 +++++- doc/manpages/swift-init.1 | 1 + swift/common/manager.py | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/swift-init b/bin/swift-init index 17dcbd0be1..b9e5680949 100755 --- a/bin/swift-init +++ b/bin/swift-init @@ -17,7 +17,8 @@ import sys from optparse import OptionParser -from swift.common.manager import Server, Manager, UnknownCommandError +from swift.common.manager import Server, Manager, UnknownCommandError, \ + KILL_WAIT USAGE = """%prog [ ...] [options] @@ -42,6 +43,9 @@ def main(): parser.add_option('-c', '--config-num', metavar="N", type="int", dest="number", default=0, help="send command to the Nth server only") + parser.add_option('-k', '--kill-wait', metavar="N", type="int", + dest="kill_wait", default=KILL_WAIT, + help="wait N seconds for processes to die (default 15)") options, args = parser.parse_args() if len(args) < 2: diff --git a/doc/manpages/swift-init.1 b/doc/manpages/swift-init.1 index 0d5431bfa0..b4e2d3f33c 100644 --- a/doc/manpages/swift-init.1 +++ b/doc/manpages/swift-init.1 @@ -107,6 +107,7 @@ allows one to use the keywords such as "all", "main" and "rest" for the .IP "-n, --no-daemon \t\t start server interactively .IP "-g, --graceful \t\t send SIGHUP to supporting servers .IP "-c N, --config-num=N \t send command to the Nth server only +.IP "-k N, --kill-wait=N \t wait N seconds for processes to die (default 15) .PD .RE diff --git a/swift/common/manager.py b/swift/common/manager.py index 855a965d09..0d380b822b 100644 --- a/swift/common/manager.py +++ b/swift/common/manager.py @@ -43,7 +43,7 @@ START_ONCE_SERVERS = REST_SERVERS # don't use that type-server.conf file and instead use their own. STANDALONE_SERVERS = ['object-expirer'] -KILL_WAIT = 15 # seconds to wait for servers to die +KILL_WAIT = 15 # seconds to wait for servers to die (by default) WARNING_WAIT = 3 # seconds to wait after message that may just be a warning MAX_DESCRIPTORS = 32768 @@ -218,8 +218,9 @@ class Manager(): for p in pids] # keep track of the pids yeiled back as killed for all servers killed_pids = set() + kill_wait = kwargs.get('kill_wait', KILL_WAIT) for server, killed_pid in watch_server_pids(server_pids, - interval=KILL_WAIT, + interval=kill_wait, **kwargs): print _("%s (%s) appears to have stopped") % (server, killed_pid) killed_pids.add(killed_pid) @@ -232,7 +233,7 @@ class Manager(): if not killed_pids.issuperset(pids): # some pids of this server were not killed print _('Waited %s seconds for %s to die; giving up') % ( - KILL_WAIT, server) + kill_wait, server) return 1 @command