Skip to content

Commit

Permalink
47774709 Added launch scripts for both standalone Flask app and running
Browse files Browse the repository at this point in the history
in GAE. Further, made necessary changes to __main__ to enable code
reloading when in DEBUG mode (which is set for development mode).
  • Loading branch information
dcharbon committed Apr 10, 2013
1 parent c21933a commit 46f705f
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ tmp
src/requirements.txt.md5
src/packages.zip
*.pyc
src/instance
3 changes: 3 additions & 0 deletions launch_gae_ggrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
# Host is set to 0.0.0.0 so that the app can be accessed by the host OS
cd src; dev_appserver.py --host 0.0.0.0 --admin_host 0.0.0.0 .
2 changes: 2 additions & 0 deletions launch_ggrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
cd src;python -m ggrc
14 changes: 14 additions & 0 deletions site-cookbooks/ggrc/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@
end
end

directory "/vagrant/src/instance" do
owner "vagrant"
group "vagrant"
action :create
end

execute "Copy development settings to instance directory" do
command "ln -s /vagrant/src/ggrc/settings/development.py /vagrant/src/instance/settings.cfg"
user "vagrant"
group "vagrant"
creates "/vagrant/src/instance/settings.cfg"
action :run
end

include_recipe "ggrc::package_env"

# Attempt to include custom local additions to the environment
Expand Down
4 changes: 3 additions & 1 deletion src/ggrc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

from flask import Flask

app = Flask('__name__')
app = Flask('ggrc', instance_relative_config=True)
app.config.from_object('ggrc.settings.default')
app.config.from_pyfile('settings.cfg')

@app.route("/")
def hello():
Expand Down
12 changes: 10 additions & 2 deletions src/ggrc/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
from ggrc import app
if __name__ == "__main__" and (__package__ is None or __package__ == ""):
import os, sys
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, parent_dir)
import ggrc
__package__ = "ggrc"
del sys, os

app.run(host='0.0.0.0')
from . import app

app.run()
Empty file added src/ggrc/settings/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions src/ggrc/settings/default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DEBUG = False
TESTING = False
3 changes: 3 additions & 0 deletions src/ggrc/settings/development.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DEBUG = True
TESTING = True
SERVER_NAME = "0.0.0.0:5000"

0 comments on commit 46f705f

Please # to comment.