gs_archive_server: add bind option to the gs_archive_server command

Currently the service by default runs on 127.0.0.1 when started. When
the service is containerized, it needs to be run on 0.0.0.0 so that
the service is accessible from outside of the container (host). Add a
flag '-b'/'bind' so that a different address can be supplied to
the service via the command line and then update the cherrypy global
configs accordingly.

BUG=chromium:1084807
TEST=Start the service by passing the -b flag and verify if it runs on
the correct address.

Change-Id: I359156c58f059c70e2e3190fd4d1f01a23ddc0fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2477498
Tested-by: Sanika Kulkarni <sanikak@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Congbin Guo <guocb@chromium.org>
Commit-Queue: Sanika Kulkarni <sanikak@chromium.org>
Auto-Submit: Sanika Kulkarni <sanikak@chromium.org>
diff --git a/gs_cache/gs_archive_server.py b/gs_cache/gs_archive_server.py
index 89d7fbb..d0326ae 100644
--- a/gs_cache/gs_archive_server.py
+++ b/gs_cache/gs_archive_server.py
@@ -469,6 +469,12 @@
       '[http://]{<hostname>|<IP>}[:<port_number>]. When skipped, the default '
       'scheme is http and port number is 80. Any other components in URL are '
       'ignored.')
+
+  parser.add_argument(
+      '-b', '--bind', default='127.0.0.1', type=str,
+      help='Option to specify alternate bind address. By default, '
+      'gs_archive_server starts on 127.0.0.1.')
+
   return parser.parse_args(argv)
 
 
@@ -495,6 +501,7 @@
 
   cherrypy.server.socket_port = args.port
   cherrypy.server.socket_file = args.socket
+  cherrypy.server.socket_host = args.bind
 
   # TODO(crbug.com/1063420) Remove the fake Omaha app once we have the long
   # term solution rolls out.