Skip to content

Commit 39f5722

Browse files
committed
Fix Python Bookshelf for GCE.
1 parent 504b3d5 commit 39f5722

File tree

10 files changed

+15
-40
lines changed

10 files changed

+15
-40
lines changed

6-pubsub/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ PyMongo==3.6.0
1212
six==1.11.0
1313
requests[security]==2.18.4
1414
honcho==1.0.1
15-
psq==0.6.0
15+
psq==0.7.0

7-gce/bookshelf/templates/base.html

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,7 @@
2929
</div>
3030
<ul class="nav navbar-nav">
3131
<li><a href="/books">Books</a></li>
32-
<li><a href="/books/mine">My Books</a></li>
3332
</ul>
34-
<p class="navbar-text navbar-right">
35-
{% if session.profile %}
36-
<a href="/logout">
37-
{% if session.profile.image %}
38-
<img class="img-circle" src="{{session.profile.image.url}}" width="24">
39-
{% endif %}
40-
{{session.profile.displayName}}
41-
</a>
42-
{% else %}
43-
<a href="/oauth2authorize">Login</a>
44-
{% endif %}
45-
</p>
4633
</div>
4734
</div>
4835
<div class="container">

7-gce/gce/deploy.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ZONE=us-central1-f
2020
GROUP=frontend-group
2121
TEMPLATE=$GROUP-tmpl
2222
MACHINE_TYPE=f1-micro
23-
IMAGE_FAMILY=debian-8
23+
IMAGE_FAMILY=debian-9
2424
IMAGE_PROJECT=debian-cloud
2525
STARTUP_SCRIPT=startup-script.sh
2626
SCOPES="userinfo-email,cloud-platform"
@@ -30,7 +30,7 @@ MIN_INSTANCES=1
3030
MAX_INSTANCES=10
3131
TARGET_UTILIZATION=0.6
3232

33-
SERVICE=frontend-web-service
33+
SERVICE=my-app-service
3434

3535
#
3636
# Instance group setup
@@ -58,7 +58,7 @@ gcloud compute instance-groups managed \
5858
--base-instance-name $GROUP \
5959
--size $MIN_INSTANCES \
6060
--template $TEMPLATE \
61-
--zone $ZONE
61+
--zone $ZONE
6262
# [END create_group]
6363

6464
# [START create_named_port]
@@ -140,7 +140,7 @@ gcloud compute instance-groups managed set-autoscaling \
140140
$GROUP \
141141
--max-num-replicas $MAX_INSTANCES \
142142
--target-load-balancing-utilization $TARGET_UTILIZATION \
143-
--zone $ZONE
143+
--zone $ZONE
144144
# [END set_autoscaling]
145145

146146
# [START create_firewall]
@@ -153,7 +153,7 @@ else
153153
--allow tcp:8080 \
154154
--source-ranges 0.0.0.0/0 \
155155
--target-tags http-server \
156-
--description "Allow port 8080 access to http-server"
156+
--description "Allow port 8080 access to http-server"
157157
fi
158158

159159
# [END create_firewall]

7-gce/gce/deployment_manager/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ resources:
2323
properties:
2424
zone: us-central1-f
2525
machine-type: n1-standard-1
26-
machine-image: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-8
26+
machine-image: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9
2727
min-instances: 1
2828
max-instances: 10
2929
target-utilization: 0.6

7-gce/gce/startup-script.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ git config --global credential.helper gcloud.sh
4545
git clone https://source.developers.google.com/p/$PROJECTID/r/[YOUR_REPO_NAME] /opt/app
4646

4747
# Install app dependencies
48-
virtualenv /opt/app/7-gce/env
48+
virtualenv -p python3 /opt/app/7-gce/env
49+
source /opt/app/7-gce/env/bin/activate
4950
/opt/app/7-gce/env/bin/pip install -r /opt/app/7-gce/requirements.txt
5051

5152
# Make sure the pythonapp user owns the application code
@@ -56,13 +57,13 @@ chown -R pythonapp:pythonapp /opt/app
5657
cat >/etc/supervisor/conf.d/python-app.conf << EOF
5758
[program:pythonapp]
5859
directory=/opt/app/7-gce
59-
command=/opt/app/7-gce/env/bin/gunicorn main:app --bind 0.0.0.0:8080
60+
command=/opt/app/7-gce/env/bin/honcho start -f ./procfile worker bookshelf
6061
autostart=true
6162
autorestart=true
6263
user=pythonapp
6364
# Environment variables ensure that the application runs inside of the
6465
# configured virtualenv.
65-
environment=VIRTUAL_ENV="/opt/app/env/7-gce",PATH="/opt/app/7-gce/env/bin",\
66+
environment=VIRTUAL_ENV="/opt/app/7-gce/env",PATH="/opt/app/7-gce/env/bin",\
6667
HOME="/home/pythonapp",USER="pythonapp"
6768
stdout_logfile=syslog
6869
stderr_logfile=syslog

7-gce/gce/teardown.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ gcloud config set compute/zone $ZONE
2020

2121
GROUP=frontend-group
2222
TEMPLATE=$GROUP-tmpl
23-
SERVICE=frontend-web-service
23+
SERVICE=my-app-service
2424

2525
gcloud compute instance-groups managed stop-autoscaling $GROUP --zone $ZONE
2626

7-gce/procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
bookshelf: gunicorn -b 0.0.0.0:$PORT main:app
1+
bookshelf: gunicorn -b 0.0.0.0:8080 main:app
22
worker: psqworker --pid /tmp/psq.pid main.books_queue
33
monitor: python monitor.py /tmp/psq.pid

7-gce/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ PyMongo==3.6.0
1212
six==1.11.0
1313
requests[security]==2.18.4
1414
honcho==1.0.1
15-
psq==0.6.0
15+
psq==0.7.0

optional-kubernetes-engine/bookshelf/templates/base.html

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,7 @@
2929
</div>
3030
<ul class="nav navbar-nav">
3131
<li><a href="/books">Books</a></li>
32-
<li><a href="/books/mine">My Books</a></li>
3332
</ul>
34-
<p class="navbar-text navbar-right">
35-
{% if session.profile %}
36-
<a href="/logout">
37-
{% if session.profile.image %}
38-
<img class="img-circle" src="{{session.profile.image.url}}" width="24">
39-
{% endif %}
40-
{{session.profile.displayName}}
41-
</a>
42-
{% else %}
43-
<a href="/oauth2authorize">Login</a>
44-
{% endif %}
45-
</p>
4633
</div>
4734
</div>
4835
<div class="container">

optional-kubernetes-engine/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ PyMongo==3.6.0
1313
six==1.11.0
1414
requests[security]==2.18.4
1515
honcho==1.0.1
16-
psq==0.6.0
16+
psq==0.7.0

0 commit comments

Comments
 (0)