Skip to content

Commit

Permalink
47774385 Simple hello world application that works standalone and in GAE
Browse files Browse the repository at this point in the history
using packages.zip for libraries.
  • Loading branch information
dcharbon committed Apr 10, 2013
1 parent d831c7d commit c21933a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ cookbooks
.vagrant
Cheffile.lock
tmp
src/requirements.txt.md5
src/packages.zip
*.pyc
33 changes: 19 additions & 14 deletions site-cookbooks/ggrc/recipes/package_env.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Create the packages.zip for use in GAE SDK or other environment.

if not File.exists?("/opt/packages.zip") or \
not File.exists?("/opt/requirements.txt.md5") or \
not system("md5sum --status --strict -c /opt/requirements.txt.md5")
if File.exists?("/opt/packages.zip")
file "/opt/packages.zip" do
packages_zip = "/vagrant/src/packages.zip"
reqs = "/vagrant/src/requirements.txt"
reqs_md5 = reqs + ".md5"

if not File.exists?(packages_zip) or \
not File.exists?(reqs_md5) or \
not system("md5sum --status --strict -c #{reqs_md5}")
if File.exists?(packages_zip)
file packages_zip do
action :delete
end
end

if File.exists?("/opt/requirements.txt.md5")
file "/opt/requirements.txt.md5" do
if File.exists?(reqs_md5)
file reqs_md5 do
action :delete
end
end
Expand Down Expand Up @@ -39,20 +43,21 @@
end

execute "Create packages.zip" do
command "zip -9mrv packages.zip .;"\
"mv packages.zip /opt/packages.zip"
command "zip -9mrv #{packages_zip} .;"\
"mv packages.zip #{packages_zip};"\
"chown vagrant:vagrant #{packages_zip}"
user "root"
group "root"
creates "/opt/packages.zip"
creates packages_zip
cwd "/tmp/packages"
action :run
end

execute "Store the md5sum of requirements.txt" do
command "md5sum /vagrant/src/requirements.txt > /opt/requirements.txt.md5"
user "root"
group "root"
creates "/opt/requirements.txt.md5"
command "md5sum #{reqs} > #{reqs_md5}"
user "vagrant"
group "vagrant"
creates reqs_md5
action :run
end

Expand Down
9 changes: 9 additions & 0 deletions src/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
application: ggrc-core
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
script: ggrc.app
11 changes: 11 additions & 0 deletions src/ggrc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sys

sys.path.insert(0, 'packages.zip')

from flask import Flask

app = Flask('__name__')

@app.route("/")
def hello():
return 'Hello World!'
3 changes: 3 additions & 0 deletions src/ggrc/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ggrc import app

app.run(host='0.0.0.0')

0 comments on commit c21933a

Please # to comment.