Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: tools/android/loading/cloud/backend/startup-script.sh

Issue 1895033002: tools/android/loading Switch the GCE worker to pull queues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@appengine
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Script executed at instance startup. It installs the required dependencies, 5 # Script executed at instance startup. It installs the required dependencies,
6 # downloads the source code, and starts a web server. 6 # downloads the source code, and starts a web server.
7 7
8 set -v 8 set -v
9 9
10 get_instance_metadata() { 10 get_instance_metadata() {
(...skipping 20 matching lines...) Expand all
31 apt-get install -yq xvfb 31 apt-get install -yq xvfb
32 32
33 # Create a pythonapp user. The application will run as this user. 33 # Create a pythonapp user. The application will run as this user.
34 useradd -m -d /home/pythonapp pythonapp 34 useradd -m -d /home/pythonapp pythonapp
35 35
36 # pip from apt is out of date, so make it update itself and install virtualenv. 36 # pip from apt is out of date, so make it update itself and install virtualenv.
37 pip install --upgrade pip virtualenv 37 pip install --upgrade pip virtualenv
38 38
39 # Download the Clovis deployment from Google Cloud Storage and unzip it. 39 # Download the Clovis deployment from Google Cloud Storage and unzip it.
40 # It is expected that the contents of the deployment have been generated using 40 # It is expected that the contents of the deployment have been generated using
41 # the tools/android/loading/gce/deploy.sh script. 41 # the tools/android/loading/cloud/backend/deploy.sh script.
42 CLOUD_STORAGE_PATH=`get_instance_metadata cloud-storage-path` 42 CLOUD_STORAGE_PATH=`get_instance_metadata cloud-storage-path`
43 DEPLOYMENT_PATH=$CLOUD_STORAGE_PATH/deployment 43 DEPLOYMENT_PATH=$CLOUD_STORAGE_PATH/deployment
44 44
45 mkdir -p /opt/app/clovis 45 mkdir -p /opt/app/clovis
46 gsutil cp gs://$DEPLOYMENT_PATH/source/source.tgz /opt/app/clovis/source.tgz 46 gsutil cp gs://$DEPLOYMENT_PATH/source/source.tgz /opt/app/clovis/source.tgz
47 tar xvf /opt/app/clovis/source.tgz -C /opt/app/clovis 47 tar xvf /opt/app/clovis/source.tgz -C /opt/app/clovis
48 rm /opt/app/clovis/source.tgz 48 rm /opt/app/clovis/source.tgz
49 49
50 # Install app dependencies 50 # Install app dependencies
51 virtualenv /opt/app/clovis/env 51 virtualenv /opt/app/clovis/env
52 /opt/app/clovis/env/bin/pip install \ 52 /opt/app/clovis/env/bin/pip install -r \
53 -r /opt/app/clovis/src/tools/android/loading/gce/pip_requirements.txt 53 /opt/app/clovis/src/tools/android/loading/cloud/backend/pip_requirements.txt
54 54
55 mkdir /opt/app/clovis/binaries 55 mkdir /opt/app/clovis/binaries
56 gsutil cp gs://$DEPLOYMENT_PATH/binaries/* /opt/app/clovis/binaries/ 56 gsutil cp gs://$DEPLOYMENT_PATH/binaries/* /opt/app/clovis/binaries/
57 unzip /opt/app/clovis/binaries/linux.zip -d /opt/app/clovis/binaries/ 57 unzip /opt/app/clovis/binaries/linux.zip -d /opt/app/clovis/binaries/
58 58
59 # Install the Chrome sandbox 59 # Install the Chrome sandbox
60 cp /opt/app/clovis/binaries/chrome_sandbox /usr/local/sbin/chrome-devel-sandbox 60 cp /opt/app/clovis/binaries/chrome_sandbox /usr/local/sbin/chrome-devel-sandbox
61 chown root:root /usr/local/sbin/chrome-devel-sandbox 61 chown root:root /usr/local/sbin/chrome-devel-sandbox
62 chmod 4755 /usr/local/sbin/chrome-devel-sandbox 62 chmod 4755 /usr/local/sbin/chrome-devel-sandbox
63 63
64 # Make sure the pythonapp user owns the application code 64 # Make sure the pythonapp user owns the application code
65 chown -R pythonapp:pythonapp /opt/app 65 chown -R pythonapp:pythonapp /opt/app
66 66
67 # Create the configuration file for this deployment. 67 # Create the configuration file for this deployment.
68 DEPLOYMENT_CONFIG_PATH=/opt/app/clovis/deployment_config.json 68 DEPLOYMENT_CONFIG_PATH=/opt/app/clovis/deployment_config.json
69 TASKQUEUE_TAG=`get_instance_metadata taskqueue_tag`
69 cat >$DEPLOYMENT_CONFIG_PATH << EOF 70 cat >$DEPLOYMENT_CONFIG_PATH << EOF
70 { 71 {
71 "project_name" : "$PROJECTID", 72 "project_name" : "$PROJECTID",
72 "cloud_storage_path" : "$CLOUD_STORAGE_PATH", 73 "cloud_storage_path" : "$CLOUD_STORAGE_PATH",
73 "chrome_path" : "/opt/app/clovis/binaries/chrome", 74 "chrome_path" : "/opt/app/clovis/binaries/chrome",
74 "src_path" : "/opt/app/clovis/src" 75 "src_path" : "/opt/app/clovis/src",
76 "taskqueue_tag" : "$TASKQUEUE_TAG"
75 } 77 }
76 EOF 78 EOF
77 79
78 # Check if auto-start is enabled 80 # Check if auto-start is enabled
79 AUTO_START=`get_instance_metadata auto-start` 81 AUTO_START=`get_instance_metadata auto-start`
80 82
81 # Exit early if auto start is not enabled. 83 # Exit early if auto start is not enabled.
82 if [ "$AUTO_START" != "true" ]; then 84 if [ "$AUTO_START" == "false" ]; then
83 exit 1 85 exit 1
84 fi 86 fi
85 87
86 # Configure supervisor to start gunicorn inside of our virtualenv and run the 88 # Configure supervisor to start the worker inside of our virtualenv.
87 # applicaiton.
88 cat >/etc/supervisor/conf.d/python-app.conf << EOF 89 cat >/etc/supervisor/conf.d/python-app.conf << EOF
89 [program:pythonapp] 90 [program:pythonapp]
90 directory=/opt/app/clovis/src/tools/android/loading/gce 91 directory=/opt/app/clovis/src/tools/android/loading/cloud/backend
91 command=/opt/app/clovis/env/bin/gunicorn --workers=1 --bind 0.0.0.0:8080 \ 92 command=python worker.py --config $DEPLOYMENT_CONFIG_PATH
92 'main:StartApp('\"$DEPLOYMENT_CONFIG_PATH\"')'
93 autostart=true 93 autostart=true
94 autorestart=true 94 autorestart=true
95 user=pythonapp 95 user=pythonapp
96 # Environment variables ensure that the application runs inside of the 96 # Environment variables ensure that the application runs inside of the
97 # configured virtualenv. 97 # configured virtualenv.
98 environment=VIRTUAL_ENV="/opt/app/clovis/env", \ 98 environment=VIRTUAL_ENV="/opt/app/clovis/env", \
99 PATH="/opt/app/clovis/env/bin:/usr/bin", \ 99 PATH="/opt/app/clovis/env/bin:/usr/bin", \
100 HOME="/home/pythonapp",USER="pythonapp", \ 100 HOME="/home/pythonapp",USER="pythonapp", \
101 CHROME_DEVEL_SANDBOX="/usr/local/sbin/chrome-devel-sandbox" 101 CHROME_DEVEL_SANDBOX="/usr/local/sbin/chrome-devel-sandbox"
102 stdout_logfile=syslog 102 stdout_logfile=syslog
103 stderr_logfile=syslog 103 stderr_logfile=syslog
104 EOF 104 EOF
105 105
106 supervisorctl reread 106 supervisorctl reread
107 supervisorctl update 107 supervisorctl update
108 108
OLDNEW
« no previous file with comments | « tools/android/loading/cloud/backend/pip_requirements.txt ('k') | tools/android/loading/cloud/backend/worker.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698