Revert "Revert "GS Cache: using vpython""

This reverts commit 30c6bbd0a05990b744de7ba9f501973172d612a7.

The original CL got reverted due to a bug in chromite. Now it has been
fixed in crosreview/1050876. Thus this CL can re-merged.
The original review for the CL is crosreview/1038646.

BUG=chromium:824580
TEST=None

Change-Id: I6112af5d9d71205dcadebe4223a60c3a2526a779
Reviewed-on: https://chromium-review.googlesource.com/1056158
Commit-Ready: Congbin Guo <guocb@chromium.org>
Tested-by: Congbin Guo <guocb@chromium.org>
Reviewed-by: Congbin Guo <guocb@chromium.org>
diff --git a/bin/gs_archive_server b/bin/gs_archive_server
index 17de3e4..06cd7ec 100755
--- a/bin/gs_archive_server
+++ b/bin/gs_archive_server
@@ -3,12 +3,16 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-# Run a archive server of Google Storage inside virtualenv
+# Run Google Storage archive server from inside virtual environment.
 set -eu
+readonly bindir=$(dirname -- "$(readlink -e -- "$0")")
+readonly homedir=$(cd "$bindir"/../gs_cache; pwd)
+export PYTHONPATH=$homedir
 
-original=$(pwd)
-cd -- "$(dirname -- "$(readlink -e -- "$0")")"
-. ./find_virtualenv.sh
-cd -- "$original"
-
-exec_python_module gs_archive_server.gs_archive_server "$@"
+# Run the server, or run tests
+if [[ $(basename "$0") == gs_archive_server_test ]]; then
+  exec vpython -vpython-spec $homedir/.vpython -m pytest \
+      "$homedir"/gs_archive_server_test.py "$@"
+else
+  exec vpython -vpython-spec $homedir/.vpython -m gs_archive_server "$@"
+fi