OLD | NEW |
(Empty) | |
| 1 How to run HTTP apps on GCE |
| 2 ==== |
| 3 |
| 4 These are the steps to create a Mojo app that handles some URLs and push it to r
un on Google Compute Engine. |
| 5 |
| 6 |
| 7 ## Set up Google Cloud Platform |
| 8 Install Google Cloud Platform SDK: https://cloud.google.com/sdk/ |
| 9 |
| 10 |
| 11 ## Authenticate |
| 12 You'll need to set a project for the Google Cloud Platform scripts. If you're a
Googler, note that you shouldn't use a corporate card for this. |
| 13 |
| 14 If you're on the Mojo team, ping jam to get added to the "mojodemos" project fir
st. |
| 15 |
| 16 If you're not on Mojo team, then create a project on Google Compute Engine and r
eplace "mojodemos" with your project-id below. Also make sure to enable the "Go
ogle Compute Engine" API" at your project's console https://console.developers.g
oogle.com |
| 17 |
| 18 |
| 19 ``` |
| 20 gcloud auth login |
| 21 gcloud config set project mojodemos |
| 22 ``` |
| 23 |
| 24 |
| 25 ## Create a VM |
| 26 Now create a VM that'll run the binary. The Debian image doesn't work because of
some GLib dependencies in our binaries that we should remove (http://crbug.com/
433886). Until then, you have to use the Ubuntu image: |
| 27 ``` |
| 28 gcloud compute instances create YOUR-VM-NAME-HERE --image ubuntu-1404-trusty-v20
141031a --image-project ubuntu-os-cloud --zone us-central1-a |
| 29 ``` |
| 30 |
| 31 Make note of the external IP address of this machine; you'll use this later to c
onnect to the Mojo app. |
| 32 |
| 33 Install some required packages: |
| 34 ``` |
| 35 gcloud compute ssh YOUR-VM-NAME-HERE --command "sudo apt-get install libgconf-2-
4 -y" --zone us-central1-a |
| 36 gcloud compute ssh YOUR-VM-NAME-HERE --command "sudo apt-get install libnss3 -y"
--zone us-central1-a |
| 37 ``` |
| 38 |
| 39 If you're not using mojodemos project-id and created a new project, add a firewa
ll rule to allow port 80: |
| 40 ``` |
| 41 gcloud compute firewall-rules create allow-http --description "Incoming http al
lowed." --allow tcp:80 |
| 42 ``` |
| 43 |
| 44 |
| 45 ## Push the Mojo binaries |
| 46 Create a directory to hold the binaries: |
| 47 ``` |
| 48 gcloud compute ssh YOUR-VM-NAME-HERE --command "mkdir ~/mojo" --zone us-central1
-a |
| 49 ``` |
| 50 |
| 51 For this example, we'll use the examples/http_handler binary which is a minimal
Mojo HTTP app. Assuming you've built the release binary: |
| 52 |
| 53 ``` |
| 54 gcloud compute copy-files out/Release/libhttp_handler.so out/Release/libhttp_ser
ver.so out/Release/libnetwork_service.so out/Release/mojo_shell YOUR-VM-NAME-HER
E:~/mojo --zone us-central1-a |
| 55 ``` |
| 56 |
| 57 |
| 58 ## Run the Mojo app |
| 59 ``` |
| 60 gcloud compute ssh YOUR-VM-NAME-HERE --command "sudo mojo/mojo_shell mojo://http
_handler" --zone us-central1-a |
| 61 ``` |
| 62 |
| 63 Now you can visit the IP address from the previous step. |
| 64 |
| 65 |
| 66 ## Delete the VM |
| 67 Once you're not using the VM anymore: |
| 68 ``` |
| 69 gcloud compute instances delete YOUR-VM-NAME-HERE --zone us-central1-a |
| 70 ``` |
OLD | NEW |