Skip to content

Commit

Permalink
Hosting app on Gunicorn.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbultrow committed Dec 17, 2015
1 parent f68508c commit b2f822b
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[bumpversion]
files = manifest.yml data_catalog/version.py
current_version = 0.4.13
current_version = 0.4.14

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ It is used to store, retrieve and to search over metadata describing data sets d

## Basic handling

### Pushing to CloudFoundry
* `./cf_build.sh`
* `cf push`

### Initial setup
* You need Python (of course).
* Install pip: `sudo apt-get install python-pip`
Expand Down Expand Up @@ -67,7 +71,7 @@ There are few development tools to handle or setup data in data-catalog:
1. [Install NATS service] (https://nats.io/) or download and configure Latest Events Service app (also available in this same githib organization). If using other then default in NATS settings configure VCAP_SERVICES. Latest Event Service is configured to work with subject that start with 'platform.' string. Example settings:
``` {"credentials": {"data-catalog-subject": "platform.data-catalog", "service-creation-subject": "platform.service-creation", "url": "nats://login:password@localhost:4222"},"label": "user-provided","name": "nats-provider"}'```

1. Running data-catalog service locally (first run prepares the index): `python -m data_catalog.app`
1. Running data-catalog service locally (first run prepares the index): `./run_app.sh`
1. Additional: some functions require Downloader and Dataset Publisher apps (also from the same Github organization as this).

#### Local development tools
Expand Down
5 changes: 5 additions & 0 deletions cf_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#/bin/bash
set -e
mkdir -p vendor/
pip install --download vendor/ -r requirements-normal.txt
pip install --download vendor/ -r requirements-native.txt --no-use-wheel
12 changes: 6 additions & 6 deletions data_catalog/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ def configure_logging():
root_logger.addHandler(negative_handler)


if __name__ == "__main__":
def get_app():
"""
To be used by the WSGI server.
"""
configure_logging()
prepare_environment()
app.run(
host='0.0.0.0',
port=_CONFIG.app_port,
debug=_CONFIG.log_level == 'DEBUG',
use_reloader=False)
return app

2 changes: 1 addition & 1 deletion data_catalog/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
#

# DO NOT TOUCH - version is changed automatically by Bumpversion
VERSION = '0.4.13'
VERSION = '0.4.14'
4 changes: 2 additions & 2 deletions manifest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
applications:
- name: data-catalog
command: python -m data_catalog.app
command: gunicorn 'data_catalog.app:get_app()' --bind :$PORT --enable-stdio-inheritance --workers `nproc`
memory: 256M
disk_quota: 256M
buildpack: python_buildpack
Expand All @@ -15,4 +15,4 @@ applications:
env:
LOG_LEVEL: "INFO"
# DO NOT TOUCH - version is changed automatically by Bumpversion
VERSION: "0.4.13"
VERSION: "0.4.14"
1 change: 1 addition & 0 deletions requirements-normal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ elasticsearch==2.1.0
Flask==0.10.1
Flask-RESTful==0.3.4
flask-restful-swagger==0.19
gunicorn==19.4.1
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ elasticsearch==2.1.0
Flask==0.10.1
Flask-RESTful==0.3.4
flask-restful-swagger==0.19
gunicorn==19.4.1
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
Expand Down
2 changes: 2 additions & 0 deletions run_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
gunicorn 'data_catalog.app:get_app()' --bind :5000 --enable-stdio-inheritance

0 comments on commit b2f822b

Please sign in to comment.