viff

changeset 1437:1772506977cc

config: Added command line option for player host and port. Sometimes it is more convenient to specify host and port numbers of the players as command line arguments when running VIFF itself, rather than by editing the configuration files. This revision enables users to override host and port numbers specified in the configuration files by command line arguments.
author Thomas P Jakobsen <tpj@cs.au.dk>
date Tue, 13 Apr 2010 20:04:29 +0200
parents a3cc11ca0ca0
children 6caded57e489
files viff/runtime.py
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Mon Apr 19 11:46:46 2010 +0200
     1.2 +++ b/viff/runtime.py	Tue Apr 13 20:04:29 2010 +0200
     1.3 @@ -530,6 +530,12 @@
     1.4          group.add_option("--no-socket-retry", action="store_true",
     1.5                           default=False, help="Fail rather than keep retrying "
     1.6                           "to connect if port is already in use.")
     1.7 +        group.add_option("--host", metavar="HOST:PORT", action="append",
     1.8 +                         help="Override host and port of players as specified "
     1.9 +                         "in the configuration file. You can use this option "
    1.10 +                         "multiple times on the command line; the first will "
    1.11 +                         "override host and port of player 1, the second that "
    1.12 +                         "of player 2, and so forth.")
    1.13  
    1.14          try:
    1.15              # Using __import__ since we do not use the module, we are
    1.16 @@ -998,6 +1004,11 @@
    1.17          from viff.passive import PassiveRuntime
    1.18          runtime_class = PassiveRuntime
    1.19  
    1.20 +    if options and options.host:
    1.21 +        for i in range(len(options.host)):
    1.22 +            players[i + 1].host, port_str = options.host[i].rsplit(":")
    1.23 +            players[i + 1].port = int(port_str)
    1.24 +
    1.25      if options and options.profile:
    1.26          # To collect profiling information we monkey patch reactor.run
    1.27          # to do the collecting. It would be nicer to simply start the