Skip to content

Commit ddd9d06

Browse files
authored
Merge pull request #238 from CLARIAH/dev
Merge updates from Dev for new release
2 parents 5e23beb + 2605dc3 commit ddd9d06

31 files changed

+425
-196
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ jobs:
1919
- stage: Tests
2020
os: osx
2121
language: objective-c
22-
env: PYENV_VERSION=3.5.2
22+
env: PYENV_VERSION=3.7.5
2323
# command to install dependencies
2424
- stage: Tests
2525
os: windows
2626
language: shell
27-
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH
27+
env:
28+
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
29+
- PYENV_VERSION=3.7.5
2830
- stage: deploy
2931
# deploy automatically to pypi
3032
before_deploy:

.travis/before_install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ if [[ $TRAVIS_BUILD_STAGE_NAME == 'Deploy' ]]; then
88
fi
99

1010
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
11-
brew install pyenv
12-
pyenv install -s $PYENV_VERSION
11+
brew install openssl pyenv
12+
CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl)" pyenv install -s $PYENV_VERSION
1313
elif [[ $TRAVIS_OS_NAME == 'windows' ]]; then
14-
choco install python
14+
choco install python --version $PYENV_VERSION
1515
fi

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ license: MIT
2525
message: "If you use this software, please cite it as below."
2626
repository-code: "https://github.com/CLARIAH/grlc"
2727
title: grlc
28-
version: "1.3.0"
28+
version: "1.3.1"

CONTRIBUTING.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,25 @@ To get started with hacking grlc, follow these steps to create a local testing e
2424
1. `docker pull clariah/grlc:latest`
2525
2. `git clone https://github.com/CLARIAH/grlc`
2626
3. `cd grlc`
27-
4. `cp docker-compose.default.yml docker-compose.yml`
28-
5. Use your favorite editor to append these lines at the end of the file `docker-compose.yml` (replace `<GRLC_CLONE_PATH>` with the absolute path where you cloned grlc in step 2):
29-
27+
4. Create a `docker-compose.yml` which matches your needs. For example:
3028
```
31-
volumes:
32-
- <GRLC_CLONE_PATH>:/home/grlc/grlc
29+
version: '2'
30+
services:
31+
grlc:
32+
build: ./
33+
restart: unless-stopped
34+
ports:
35+
- "8001:80"
36+
environment:
37+
- DEBUG=true
38+
- USERMAP_GID=1000
39+
- USERMAP_UID=1000
40+
- GRLC_GITHUB_ACCESS_TOKEN=xxx
41+
- GRLC_SERVER_NAME=grlc.io
3342
```
3443

35-
6. `docker-compose up`
36-
7. Your local grlc instance should be available at http://localhost:8001 and should respond to code modifications you make on `<GRLC_CLONE_PATH>`
44+
5. `docker-compose up`
45+
6. Your local grlc instance should be available at http://localhost:8001 and should respond to code modifications you make on `<GRLC_CLONE_PATH>`
3746

3847
You're good to pick any issue at the [issue tracker](https://github.com/CLARIAH/grlc/issues) marked as **enhancement** and start implementing it :)
3948

README.md

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -43,69 +43,74 @@ For a quick usage tutorial check out our wiki walkthrough [here](https://github.
4343

4444
## Install and run
4545

46-
Running via [docker](https://www.docker.com/) is the easiest and preferred form of deploying grlc. You'll need a working installation of [docker](https://www.docker.com/) and [docker-compose](https://docs.docker.com/compose/). To deploy grlc, just pull the latest image from Docker hub, and run docker compose with a `docker-compose.yml` that suits your needs (an [example](docker-compose.default.yml) is provided in the root directory):
46+
### grlc.io
47+
The easiest way to use grlc is by visiting [grlc.io/](http://grlc.io/) and using this service to convert SPARQL queries on your github repo into a RESTful API.
4748

48-
<pre>
49-
git clone https://github.com/CLARIAH/grlc
50-
cd grlc
51-
docker pull clariah/grlc
52-
docker-compose -f docker-compose.default.yml up
53-
</pre>
54-
55-
To run directly from Docker Hub it is sufficient to do:
56-
```
57-
docker run --rm -p 8088:80 -e GRLC_SERVER_NAME=grlc.io -e GRLC_GITHUB_ACCESS_TOKEN=xxx -e GRLC_SPARQL_ENDPOINT=http://dbpedia.org/sparql -e DEBUG=true clariah/grlc
58-
```
59-
60-
(You can omit the first two commands if you just copy [this file](docker-compose.default.yml) somehwere in your filesystem)
61-
If you use the supplied `docker-compose.default.yml` your grlc instance will be available at http://localhost:8001
62-
63-
If you want your grlc instance to forward queries to a different service than `grlc.io`, edit the `GRLC_SERVER_NAME` variable in your `docker-compose.yml` or `docker-compose.default.yml` file.
64-
65-
In order for grlc to communicate with GitHub, you'll need to tell grlc what your access token is:
66-
67-
1. Get a GitHub personal access token. In your GitHub's profile page, go to _Settings_, then _Developer settings_, _Personal access tokens_, and _Generate new token_
68-
2. You'll get an access token string, copy it and save it somewhere safe (GitHub won't let you see it again!)
69-
3. Edit your `docker-compose.yml` or `docker-compose.default.yml` file, and paste this token as value of the environment variable GRLC_GITHUB_ACCESS_TOKEN
70-
71-
If you want to run grlc at system boot as a service, you can find example upstart scripts at [upstart/](upstart/grlc-docker.conf)
72-
73-
### Alternative install methods
74-
75-
Through these you'll miss some cool docker bundled features (like nginx-based caching). We provide these alternatives just for testing, development scenarios, or docker compatibility reasons.
49+
### Pip
50+
If you want to run grlc locally or use it as a library, you can install grlc on your machine. Grlc is [registered in PyPi](https://pypi.org/project/grlc/) so you can install it using pip.
7651

7752
#### Prerequisites
7853
- Python3
7954
- development files:
80-
8155
```bash
8256
sudo apt-get install libevent-dev python-all-dev
8357
```
8458

85-
#### pip
86-
87-
If you want to use grlc as a library, you'll find it useful to install via `pip`.
88-
89-
<pre>
59+
#### pip install
60+
```bash
9061
pip install grlc
91-
grlc-server
92-
</pre>
62+
```
9363

94-
More details can be found at [grlc's PyPi page](https://pypi.python.org/pypi/grlc) (thanks to [c-martinez](https://github.com/c-martinez)!).
64+
Grlc includes a command line tool which you can use to start your own grlc server:
65+
```bash
66+
grlc-server
67+
```
9568

96-
#### Flask application
69+
#### Using gunicorn
70+
You can run grlc using gunicorn as follows:
71+
```bash
72+
gunicorn grlc.server:app
73+
```
9774

98-
You can run grlc natively as follows:
75+
If you want to use your own gunicorn configuration, for example `gunicorn_config.py`:
76+
```
77+
workers = 5
78+
worker_class = 'gevent'
79+
bind = '0.0.0.0:8088'
9980
```
100-
gunicorn -c gunicorn_config.py src.server:app
81+
Then you can run it as:
82+
```bash
83+
gunicorn -c gunicorn_config.py grlc.server:app
10184
```
10285

10386
**Note:** Since `gunicorn` does not work under Windows, you can use `waitress` instead:
87+
```bash
88+
waitress-serve --port=8088 grlc.server:app
10489
```
105-
waitress-serve --port=8088 src.server:app
90+
91+
#### Grlc library
92+
You can use grlc as a library directly from your own python script. See the [usage example](https://github.com/CLARIAH/grlc/blob/master/doc/notebooks/GrlcFromNotebook.ipynb) to find out more.
93+
94+
### Docker
95+
To run grlc via [docker](https://www.docker.com/), you'll need a working installation of docker. To deploy grlc, just pull the [latest image from Docker hub](https://hub.docker.com/r/clariah/grlc/). :
96+
```bash
97+
docker run -it --rm -p 8088:80 clariah/grlc
10698
```
10799

108-
You can also find an example [here](https://github.com/CLARIAH/grlc/blob/master/docker-assets/entrypoint.sh#L24)
100+
The docker image allows you to setup several environment variable such as `GRLC_SERVER_NAME` `GRLC_GITHUB_ACCESS_TOKEN` and `GRLC_SPARQL_ENDPOINT`:
101+
```bash
102+
docker run -it --rm -p 8088:80 -e GRLC_SERVER_NAME=grlc.io -e GRLC_GITHUB_ACCESS_TOKEN=xxx -e GRLC_SPARQL_ENDPOINT=http://dbpedia.org/sparql -e DEBUG=true clariah/grlc
103+
```
104+
105+
## Access token
106+
107+
In order for grlc to communicate with GitHub, you'll need to tell grlc what your access token is:
108+
109+
1. Get a GitHub personal access token. In your GitHub's profile page, go to _Settings_, then _Developer settings_, _Personal access tokens_, and _Generate new token_
110+
2. You'll get an access token string, copy it and save it somewhere safe (GitHub won't let you see it again!)
111+
3. Edit your `docker-compose.yml` or `docker-compose.default.yml` file, and paste this token as value of the environment variable GRLC_GITHUB_ACCESS_TOKEN
112+
113+
If you want to run grlc at system boot as a service, you can find example upstart scripts at [upstart/](upstart/grlc-docker.conf)
109114

110115
## Usage
111116

bin/grlc-server

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1-
#!/home/amp/src/grlc/bin/python2
1+
#!/usr/bin/env python
2+
"""Grlc server.
23
4+
Usage:
5+
grlc-server [--port=PORT]
6+
7+
Options:
8+
--port=PORT Port the server runs on [default: 8088].
9+
"""
10+
from docopt import docopt
311
from grlc.server import app as grlc_app
12+
from grlc import __version__ as grlc_version
413
from grlc import static
514
from sys import platform
615

716

8-
def runViaWaitress():
17+
def runViaWaitress(port=8088):
918
from waitress import serve
10-
serve(grlc_app, listen='*:8088')
19+
serve(grlc_app, listen='*:%d'%port)
1120

12-
def runViaGunicorn():
21+
def runViaGunicorn(port=8088):
1322
from gunicorn.app.base import BaseApplication
1423
from gunicorn.six import iteritems
1524
class StandaloneApplication(BaseApplication):
@@ -28,14 +37,17 @@ def runViaGunicorn():
2837
return self.application
2938

3039
options = {
31-
'bind': '%s:%d' % ('0.0.0.0', 8088),
40+
'bind': '%s:%d' % ('0.0.0.0', port),
3241
'workers': 20,
3342
'debug': static.LOG_DEBUG_MODE
3443
}
3544
StandaloneApplication(grlc_app, options).run()
3645

3746
if __name__ == '__main__':
47+
args = docopt(__doc__, version='Grlc %s server'%grlc_version)
48+
port = int(args['--port'])
49+
3850
if platform=='win32':
39-
runViaWaitress()
51+
runViaWaitress(port)
4052
else:
41-
runViaGunicorn()
53+
runViaGunicorn(port)

config.default.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ server_name = grlc.io
1212
user = none
1313
password = none
1414
# Logging level
15-
debug = True
15+
debug = False

docker-assets/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ case ${1} in
2525
# configure default sparql endpoint
2626
sed -i "s|http://dbpedia.org/sparql|${GRLC_SPARQL_ENDPOINT}|" config.ini
2727

28-
gunicorn -c gunicorn_config.py src.server:app
28+
grlc-server --port=8088
2929
# migrate_database
3030
# rm -rf /var/run/supervisor.sock
3131
# exec /usr/bin/supervisord -nc /etc/supervisor/supervisord.conf

docker-compose.default.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

gunicorn_config.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)