OLD | NEW |
| (Empty) |
1 # Clovis in the Cloud: Developer Guide | |
2 | |
3 This document describes how to collect Chromium traces using Google Compute | |
4 Engine. | |
5 | |
6 [TOC] | |
7 | |
8 ## Initial setup | |
9 | |
10 Install the [gcloud command line tool][1]. | |
11 | |
12 ## Deploy the code | |
13 | |
14 ```shell | |
15 # Build Chrome (do not use the component build). | |
16 BUILD_DIR=out/Release | |
17 ninja -C $BUILD_DIR -j1000 -l60 chrome chrome_sandbox | |
18 | |
19 # Deploy to GCE | |
20 # CLOUD_STORAGE_PATH is the path in Google Cloud Storage under which the | |
21 # Clovis deployment will be uploaded. | |
22 | |
23 ./tools/android/loading/gce/deploy.sh $BUILD_DIR $CLOUD_STORAGE_PATH | |
24 ``` | |
25 | |
26 ## Start the app in the cloud | |
27 | |
28 Create an instance using latest ubuntu LTS: | |
29 | |
30 ```shell | |
31 gcloud compute instances create clovis-tracer-1 \ | |
32 --machine-type n1-standard-1 \ | |
33 --image ubuntu-14-04 \ | |
34 --zone europe-west1-c \ | |
35 --scopes cloud-platform \ | |
36 --metadata cloud-storage-path=$CLOUD_STORAGE_PATH,auto-start=true \ | |
37 --metadata-from-file \ | |
38 startup-script=$CHROMIUM_SRC/tools/android/loading/gce/startup-script.sh | |
39 ``` | |
40 | |
41 **Note:** To start an instance without automatically starting the app on it, | |
42 remove the `--metadata auto-start=true` argument. This can be useful when doing | |
43 iterative development on the instance, to be able to restart the app manually. | |
44 | |
45 This should output the IP address of the instance. | |
46 Otherwise the IP address can be retrieved by doing: | |
47 | |
48 ```shell | |
49 gcloud compute instances list | |
50 ``` | |
51 | |
52 **Note:** It can take a few minutes for the instance to start. You can follow | |
53 the progress of the startup script on the gcloud console web interface (menu | |
54 "Compute Engine" > "VM instances" then click on your instance and scroll down to | |
55 see the "Serial console output") or from the command line using: | |
56 | |
57 ```shell | |
58 gcloud compute instances get-serial-port-output clovis-tracer-1 | |
59 ``` | |
60 | |
61 ## Use the app | |
62 | |
63 Check that `http://<instance-ip>:8080/test` prints `hello` when opened in a | |
64 browser. | |
65 | |
66 To send a list of URLs to process: | |
67 | |
68 ```shell | |
69 curl -X POST -d @urls.json http://<instance-ip>:8080/set_tasks | |
70 ``` | |
71 | |
72 where `urls.json` is a JSON dictionary with the keys: | |
73 | |
74 * `urls`: array of URLs | |
75 * `repeat_count`: Number of times each URL will be loaded. Each load of a URL | |
76 generates a separate trace file. Optional. | |
77 * `emulate_device`: Name of the device to emulate. Optional. | |
78 * `emulate_network`: Type of network emulation. Optional. | |
79 | |
80 You can follow the progress at `http://<instance-ip>:8080/status`. | |
81 | |
82 ## Stop the app in the cloud | |
83 | |
84 ```shell | |
85 gcloud compute instances delete clovis-tracer-1 | |
86 ``` | |
87 | |
88 ## Connect to the instance with SSH | |
89 | |
90 ```shell | |
91 gcloud compute ssh clovis-tracer-1 | |
92 ``` | |
93 | |
94 ## Use the app locally | |
95 | |
96 From a new directory, set up a local environment: | |
97 | |
98 ```shell | |
99 virtualenv env | |
100 source env/bin/activate | |
101 pip install -r $CHROMIUM_SRC/tools/android/loading/gce/pip_requirements.txt | |
102 ``` | |
103 | |
104 Create a JSON file describing the deployment configuration: | |
105 | |
106 ```shell | |
107 # CONFIG_FILE is the output json file. | |
108 # PROJECT_NAME is the Google Cloud project. | |
109 # CLOUD_STORAGE_PATH is the path in Google Storage where generated traces will | |
110 # be stored. | |
111 # CHROME_PATH is the path to the Chrome executable on the host. | |
112 # CHROMIUM_SRC is the Chromium src directory. | |
113 cat >$CONFIG_FILE << EOF | |
114 { | |
115 "project_name" : "$PROJECT_NAME", | |
116 "cloud_storage_path" : "$CLOUD_STORAGE_PATH", | |
117 "chrome_path" : "$CHROME_PATH", | |
118 "src_path" : "$CHROMIUM_SRC" | |
119 } | |
120 EOF | |
121 ``` | |
122 | |
123 Launch the app, passing the path to the deployment configuration file: | |
124 | |
125 ```shell | |
126 gunicorn --workers=1 --bind 127.0.0.1:8080 \ | |
127 --pythonpath $CHROMIUM_SRC/tools/android/loading/gce \ | |
128 'main:StartApp('\"$CONFIG_FILE\"')' | |
129 ``` | |
130 | |
131 You can now [use the app][2], which is located at http://localhost:8080. | |
132 | |
133 Tear down the local environment: | |
134 | |
135 ```shell | |
136 deactivate | |
137 ``` | |
138 | |
139 [1]: https://cloud.google.com/sdk | |
140 [2]: #Use-the-app | |
OLD | NEW |