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
This commit is contained in:
gholt 2012-12-17 23:06:22 +00:00
parent 2a9bf20065
commit 4fcbeff22f
3 changed files with 10 additions and 4 deletions

View File

@ -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 <server> [<server> ...] <command> [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:

View File

@ -107,6 +107,7 @@ allows one to use the keywords such as "all", "main" and "rest" for the <server>
.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

View File

@ -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