OLD | NEW |
1 # Clovis in the Cloud: Developer Guide | 1 # Clovis in the Cloud: Developer Guide |
2 | 2 |
3 This document describes how to collect Chromium traces using Google Compute | 3 This document describes how to collect Chromium traces using Google Compute |
4 Engine. | 4 Engine. |
5 | 5 |
6 [TOC] | 6 [TOC] |
7 | 7 |
8 ## Initial setup | 8 ## Initial setup |
9 | 9 |
10 Install the [gcloud command line tool][1]. | 10 Install the [gcloud command line tool][1]. |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 ## Start the app in the cloud | 26 ## Start the app in the cloud |
27 | 27 |
28 Create an instance using latest ubuntu LTS: | 28 Create an instance using latest ubuntu LTS: |
29 | 29 |
30 ```shell | 30 ```shell |
31 gcloud compute instances create clovis-tracer-1 \ | 31 gcloud compute instances create clovis-tracer-1 \ |
32 --machine-type n1-standard-1 \ | 32 --machine-type n1-standard-1 \ |
33 --image ubuntu-14-04 \ | 33 --image ubuntu-14-04 \ |
34 --zone europe-west1-c \ | 34 --zone europe-west1-c \ |
35 --scopes cloud-platform \ | 35 --scopes cloud-platform,https://www.googleapis.com/auth/cloud-taskqueue \ |
36 --metadata cloud-storage-path=$CLOUD_STORAGE_PATH,auto-start=true \ | 36 --metadata cloud-storage-path=$CLOUD_STORAGE_PATH,taskqueue_tag=some_tag \ |
37 --metadata-from-file \ | 37 --metadata-from-file \ |
38 startup-script=$CHROMIUM_SRC/tools/android/loading/gce/startup-script.sh | 38 startup-script=$CHROMIUM_SRC/tools/android/loading/gce/startup-script.sh |
39 ``` | 39 ``` |
40 | 40 |
41 **Note:** To start an instance without automatically starting the app on it, | 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 | 42 add a `auto-start=false` metadata. This can be useful when doing iterative |
43 iterative development on the instance, to be able to restart the app manually. | 43 development on the instance, to be able to restart the app manually. |
44 | 44 |
45 This should output the IP address of the instance. | 45 This should output the IP address of the instance. |
46 Otherwise the IP address can be retrieved by doing: | 46 Otherwise the IP address can be retrieved by doing: |
47 | 47 |
48 ```shell | 48 ```shell |
49 gcloud compute instances list | 49 gcloud compute instances list |
50 ``` | 50 ``` |
51 | 51 |
52 **Note:** It can take a few minutes for the instance to start. You can follow | 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 | 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 | 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: | 55 see the "Serial console output") or from the command line using: |
56 | 56 |
57 ```shell | 57 ```shell |
58 gcloud compute instances get-serial-port-output clovis-tracer-1 | 58 gcloud compute instances get-serial-port-output clovis-tracer-1 |
59 ``` | 59 ``` |
60 | 60 |
61 ## Use the app | 61 ## Use the app |
62 | 62 |
63 Check that `http://<instance-ip>:8080/test` prints `hello` when opened in a | 63 Create tasks from the associated AppEngine application, see [documentation][3]. |
64 browser. | 64 Make sure the `taskqueue_tag` of the AppEngine request matches the one of the |
65 | 65 ComputeEngine instances. |
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 | 66 |
82 ## Stop the app in the cloud | 67 ## Stop the app in the cloud |
83 | 68 |
84 ```shell | 69 ```shell |
85 gcloud compute instances delete clovis-tracer-1 | 70 gcloud compute instances delete clovis-tracer-1 |
86 ``` | 71 ``` |
87 | 72 |
88 ## Connect to the instance with SSH | 73 ## Connect to the instance with SSH |
89 | 74 |
90 ```shell | 75 ```shell |
91 gcloud compute ssh clovis-tracer-1 | 76 gcloud compute ssh clovis-tracer-1 |
92 ``` | 77 ``` |
93 | 78 |
94 ## Use the app locally | 79 ## Use the app locally |
95 | 80 |
96 From a new directory, set up a local environment: | 81 From a new directory, set up a local environment: |
97 | 82 |
98 ```shell | 83 ```shell |
99 virtualenv env | 84 virtualenv env |
100 source env/bin/activate | 85 source env/bin/activate |
101 pip install -r $CHROMIUM_SRC/tools/android/loading/gce/pip_requirements.txt | 86 pip install -r $CHROMIUM_SRC/tools/android/loading/gce/pip_requirements.txt |
102 ``` | 87 ``` |
103 | 88 |
| 89 The first time, you may need to get more access tokens: |
| 90 |
| 91 ```shell |
| 92 gcloud beta auth application-default login --scopes \ |
| 93 https://www.googleapis.com/auth/cloud-taskqueue \ |
| 94 https://www.googleapis.com/auth/cloud-platform |
| 95 ``` |
| 96 |
104 Create a JSON file describing the deployment configuration: | 97 Create a JSON file describing the deployment configuration: |
105 | 98 |
106 ```shell | 99 ```shell |
107 # CONFIG_FILE is the output json file. | 100 # CONFIG_FILE is the output json file. |
108 # PROJECT_NAME is the Google Cloud project. | 101 # PROJECT_NAME is the Google Cloud project. |
109 # CLOUD_STORAGE_PATH is the path in Google Storage where generated traces will | 102 # CLOUD_STORAGE_PATH is the path in Google Storage where generated traces will |
110 # be stored. | 103 # be stored. |
111 # CHROME_PATH is the path to the Chrome executable on the host. | 104 # CHROME_PATH is the path to the Chrome executable on the host. |
112 # CHROMIUM_SRC is the Chromium src directory. | 105 # CHROMIUM_SRC is the Chromium src directory. |
113 cat >$CONFIG_FILE << EOF | 106 cat >$CONFIG_FILE << EOF |
114 { | 107 { |
115 "project_name" : "$PROJECT_NAME", | 108 "project_name" : "$PROJECT_NAME", |
116 "cloud_storage_path" : "$CLOUD_STORAGE_PATH", | 109 "cloud_storage_path" : "$CLOUD_STORAGE_PATH", |
117 "chrome_path" : "$CHROME_PATH", | 110 "chrome_path" : "$CHROME_PATH", |
118 "src_path" : "$CHROMIUM_SRC" | 111 "src_path" : "$CHROMIUM_SRC", |
| 112 "taskqueue_tag" : "some_tag" |
119 } | 113 } |
120 EOF | 114 EOF |
121 ``` | 115 ``` |
122 | 116 |
123 Launch the app, passing the path to the deployment configuration file: | 117 Launch the app, passing the path to the deployment configuration file: |
124 | 118 |
125 ```shell | 119 ```shell |
126 gunicorn --workers=1 --bind 127.0.0.1:8080 \ | 120 python $CHROMIUM_SRC/tools/android/loading/gce/worker.py --config $CONFIG_FILE |
127 --pythonpath $CHROMIUM_SRC/tools/android/loading/gce \ | |
128 'main:StartApp('\"$CONFIG_FILE\"')' | |
129 ``` | 121 ``` |
130 | 122 |
131 You can now [use the app][2], which is located at http://localhost:8080. | 123 You can now [use the app][2]. |
132 | 124 |
133 Tear down the local environment: | 125 Tear down the local environment: |
134 | 126 |
135 ```shell | 127 ```shell |
136 deactivate | 128 deactivate |
137 ``` | 129 ``` |
138 | 130 |
139 [1]: https://cloud.google.com/sdk | 131 [1]: https://cloud.google.com/sdk |
140 [2]: #Use-the-app | 132 [2]: #Use-the-app |
| 133 [3]: ../frontend/README.md |
OLD | NEW |