Commit b2719bc3435acd071d04159fb106089a097d0b62
1 parent
dc14aff7
Exists in
master
Adiciona Makefile, corrige template settings_local
Showing
3 changed files
with
90 additions
and
9 deletions
Show diff stats
@@ -0,0 +1,79 @@ | @@ -0,0 +1,79 @@ | ||
1 | +PROJECT_NAME = corretor | ||
2 | +VLIBRAS_NAME = vlibras-wiki | ||
3 | +PYBOSSA_CONF = /etc/apache2/sites-available/pybossa.conf | ||
4 | +PROJECT_DIR = $(CURDIR) | ||
5 | +SED_REPLACE_ALL = sed -i "s/$(1)/$(2)/g" "$(3)" | ||
6 | +SED_REPLACE_ALL_PATH = sed -i "s\#$(1)\#$(2)\#g" "$(3)" | ||
7 | + | ||
8 | +ifndef LOCALHOST | ||
9 | + ifndef NETWORK_INTERFACE | ||
10 | + NETWORK_INTERFACE := $(shell ip route | awk '{print $$5; exit}') | ||
11 | + endif | ||
12 | + ifdef NETWORK_INTERFACE | ||
13 | + LOCALHOST := $(shell ip addr list ${NETWORK_INTERFACE} | grep "inet " | cut -d ' ' -f6 | cut -d/ -f1) | ||
14 | + endif | ||
15 | +endif | ||
16 | + | ||
17 | +ifndef LOCALHOST | ||
18 | + LOCALHOST := localhost | ||
19 | +endif | ||
20 | + | ||
21 | +install: uninstall config | ||
22 | + @( \ | ||
23 | + virtualenv ./env/; \ | ||
24 | + . ./env/bin/activate; \ | ||
25 | + pip install -U pip; \ | ||
26 | + pip install -U uwsgi; \ | ||
27 | + pip install -U ndg-httpsclient; \ | ||
28 | + pip install -r requirements.txt; \ | ||
29 | + ) | ||
30 | +ifdef PYBOSSA_API_KEY | ||
31 | + @ curl "http://${LOCALHOST}/${PROJECT_NAME}-backend/create_project" && echo "" | ||
32 | + @ echo "http://${LOCALHOST}/${PROJECT_NAME}-backend/create_project" | ||
33 | +endif | ||
34 | + | ||
35 | +config: | ||
36 | + @ $(info Using interface: ${NETWORK_INTERFACE}) | ||
37 | + @ $(info Using local IP: ${LOCALHOST}) | ||
38 | + @ cp settings_local.py.tmpl settings_local.py | ||
39 | + @ $(call SED_REPLACE_ALL_PATH,<path-to-project>,${PROJECT_DIR},settings_local.py) | ||
40 | + @ $(call SED_REPLACE_ALL,localhost,${LOCALHOST},settings_local.py) | ||
41 | +ifdef PYBOSSA_API_KEY | ||
42 | + @ $(call SED_REPLACE_ALL,my-api-key,${PYBOSSA_API_KEY},settings_local.py) | ||
43 | +endif | ||
44 | + @ cp ./contrib/${PROJECT_NAME}.wsgi.tmpl ./contrib/${PROJECT_NAME}.wsgi | ||
45 | + @ $(call SED_REPLACE_ALL_PATH,<path-to-project>,${PROJECT_DIR},./contrib/${PROJECT_NAME}.wsgi) | ||
46 | + @ cp ./contrib/apache/${PROJECT_NAME}.conf.tmpl ./contrib/apache/${PROJECT_NAME}.conf | ||
47 | + @ $(call SED_REPLACE_ALL,ServerName localhost,ServerName ${LOCALHOST},./contrib/apache/${PROJECT_NAME}.conf) | ||
48 | + @ $(call SED_REPLACE_ALL,user1,$$USER,./contrib/apache/${PROJECT_NAME}.conf) | ||
49 | + @ $(call SED_REPLACE_ALL,group1,$$USER,./contrib/apache/${PROJECT_NAME}.conf) | ||
50 | + @ $(call SED_REPLACE_ALL_PATH,<path-to-project>,${PROJECT_DIR},./contrib/apache/${PROJECT_NAME}.conf) | ||
51 | + @ sudo cp -u ${PYBOSSA_CONF} /etc/apache2/sites-available/${VLIBRAS_NAME}.conf | ||
52 | + @ if grep -q "${PROJECT_NAME}" "/etc/apache2/sites-available/${VLIBRAS_NAME}.conf"; \ | ||
53 | + then \ | ||
54 | + echo "A previous WSGI daemon definition for '${PROJECT_NAME}' in: /etc/apache2/sites-available/${VLIBRAS_NAME}.conf"; \ | ||
55 | + else \ | ||
56 | + sudo sed -i -e "/Header/,/VirtualHost>/d" /etc/apache2/sites-available/${VLIBRAS_NAME}.conf; \ | ||
57 | + sudo sed -n -e '/WSGIDaemonProcess/,/VirtualHost>/p' ./contrib/apache/${PROJECT_NAME}.conf | \ | ||
58 | + sudo tee -a /etc/apache2/sites-available/${VLIBRAS_NAME}.conf > /dev/null; \ | ||
59 | + fi | ||
60 | + @ sudo a2dissite pybossa.conf | ||
61 | + @ sudo a2ensite ${VLIBRAS_NAME}.conf | ||
62 | + @ sudo apachectl configtest | ||
63 | + @ sudo service apache2 reload | ||
64 | + | ||
65 | +clean: | ||
66 | + @ find . -regextype posix-awk -regex "(.*.log|.*.pyc)" -type f -print -delete | ||
67 | + | ||
68 | +uninstall: clean | ||
69 | + @ rm -rf ./env/ | ||
70 | + @ rm -f ./settings_local.py | ||
71 | + @ rm -f ./contrib/${PROJECT_NAME}.wsgi | ||
72 | + @ sudo rm -f /etc/apache2/sites-available/${VLIBRAS_NAME}.conf | ||
73 | + @ sudo rm -f /etc/apache2/sites-enabled/${VLIBRAS_NAME}.conf | ||
74 | + | ||
75 | +run: | ||
76 | + @ ( \ | ||
77 | + . ./env/bin/activate; \ | ||
78 | + python main.py; \ | ||
79 | + ) |
contrib/apache/corretor.conf.tmpl
1 | <VirtualHost *:80> | 1 | <VirtualHost *:80> |
2 | - ServerName localhost | 2 | + ServerName localhost |
3 | 3 | ||
4 | WSGIDaemonProcess corretor user=user1 group=group1 threads=5 | 4 | WSGIDaemonProcess corretor user=user1 group=group1 threads=5 |
5 | WSGIScriptAlias /corretor-backend <path-to-project>/contrib/corretor.wsgi | 5 | WSGIScriptAlias /corretor-backend <path-to-project>/contrib/corretor.wsgi |
@@ -19,10 +19,10 @@ | @@ -19,10 +19,10 @@ | ||
19 | Require all granted | 19 | Require all granted |
20 | </Directory> | 20 | </Directory> |
21 | 21 | ||
22 | - Header set Access-Control-Allow-Origin "*" | 22 | + Header set Access-Control-Allow-Origin "*" |
23 | 23 | ||
24 | - ServerAdmin webmaster@localhost | 24 | + ServerAdmin webmaster@localhost |
25 | 25 | ||
26 | - ErrorLog ${APACHE_LOG_DIR}/error.log | ||
27 | - CustomLog ${APACHE_LOG_DIR}/access.log combined | 26 | + ErrorLog ${APACHE_LOG_DIR}/error.log |
27 | + CustomLog ${APACHE_LOG_DIR}/access.log combined | ||
28 | </VirtualHost> | 28 | </VirtualHost> |
settings_local.py.tmpl
1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
2 | # Corretor Server Configuration | 2 | # Corretor Server Configuration |
3 | SERVER_HOST = "localhost" | 3 | SERVER_HOST = "localhost" |
4 | -SERVER_PORT = 8000 | 4 | +SERVER_PORT = 8001 |
5 | AGREEMENT_NUMBER = 2 | 5 | AGREEMENT_NUMBER = 2 |
6 | -UPLOAD_FOLDER = "<path-to-corretor>/view/uploads" | 6 | +UPLOAD_FOLDER = "<path-to-project>/view/uploads" |
7 | +API_HOST = "http://localhost:201" | ||
8 | +API_DB_HOST = "http://localhost:200" | ||
7 | 9 | ||
8 | # Apache Configuration | 10 | # Apache Configuration |
9 | -APACHE_HOST = False | 11 | +APACHE_HOST = True |
10 | APACHE_HOST_ENDPOINT = "/corretor-backend" | 12 | APACHE_HOST_ENDPOINT = "/corretor-backend" |
11 | APACHE_STATIC_FILES_ENDPOINT = "/corretor" | 13 | APACHE_STATIC_FILES_ENDPOINT = "/corretor" |
12 | 14 | ||
@@ -14,5 +16,5 @@ APACHE_STATIC_FILES_ENDPOINT = "/corretor" | @@ -14,5 +16,5 @@ APACHE_STATIC_FILES_ENDPOINT = "/corretor" | ||
14 | PYBOSSA_APP_NAME = "Corretor de Sinais" | 16 | PYBOSSA_APP_NAME = "Corretor de Sinais" |
15 | PYBOSSA_APP_SHORT_NAME = "corretor_sinais" | 17 | PYBOSSA_APP_SHORT_NAME = "corretor_sinais" |
16 | PYBOSSA_APP_DESCRIPTION = "Esse projeto ajudará a comunidade a melhorar sinais com movimentos complexos." | 18 | PYBOSSA_APP_DESCRIPTION = "Esse projeto ajudará a comunidade a melhorar sinais com movimentos complexos." |
17 | -PYBOSSA_ENDPOINT = "http://localhost:5000" | 19 | +PYBOSSA_ENDPOINT = "http://localhost/pybossa" |
18 | PYBOSSA_API_KEY = "my-api-key" | 20 | PYBOSSA_API_KEY = "my-api-key" |
19 | \ No newline at end of file | 21 | \ No newline at end of file |