devserver: Allocate a free port when given --port=0
This is needed in order for avoid port collisions when running multiple
devserver instances in the lab. In essence, there is nothing to it but
documenting this behavior and relying on a corresponding change to
CherryPy to support this functionality.
BUG=chromium:333082
TEST=Available port allocated with --port=0.
CQ-DEPEND=CL:184925
Change-Id: I04352b763494df900edfad56fed24da9b66a035e
Reviewed-on: https://chromium-review.googlesource.com/184915
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/devserver.py b/devserver.py
index 0e93465..1e27be3 100755
--- a/devserver.py
+++ b/devserver.py
@@ -1055,7 +1055,9 @@
help='writable static directory')
parser.add_option('--port',
default=8080, type='int',
- help='port for the dev server to use (default: 8080)')
+ help=('port for the dev server to use; if zero, then we '
+ 'attempt to allocate an available port '
+ '(default: 8080)'))
parser.add_option('-t', '--test_image',
action='store_true',
help='Deprecated.')