This repository has been archived by the owner on Nov 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
100 lines (80 loc) · 3.02 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
ifndef REFL_INSTALL_DIR
prefix = /var/www/web_reflectivity
else
prefix = $(REFL_INSTALL_DIR)
endif
app_dir := web_reflectivity
DJANGO_COMPATIBLE:=$(shell python -c "import django;t=0 if django.VERSION[1]<9 else 1; print t")
DJANGO_VERSION:=$(shell python -c "import django;print django.__version__")
ifndef PYTHON
PYTHON := python
endif
all:
@echo "Run make install to install the live data server"
check:
# Check dependencies
@python -c "import django" || echo "\nERROR: Django is not installed: www.djangoproject.com\n"
@python -c "import psycopg2" || echo "\nWARNING: psycopg2 is not installed: http://initd.org/psycopg\n"
@python -c "import cython" || echo "\nWARNING: cython is not installed\n"
@python -c "import pandas" || echo "\nWARNING: pandas is not installed\n"
@python -c "import plotly" || echo "\nWARNING: plotly is not installed\n"
@python -c "import plotly.offline" || echo "\nWARNING: plotly.offline is not installed\n"
ifeq ($(DJANGO_COMPATIBLE),1)
@echo "Detected Django $(DJANGO_VERSION)"
else
$(error Detected Django $(DJANGO_VERSION) < 1.9. The web monitor requires at least Django 1.9)
endif
deps:
$(PYTHON) -m pip install -r requirements.txt
install: webapp
webapp/core:
# Make sure the install directories exist
test -d $(prefix) || mkdir -m 0755 -p $(prefix)
test -d $(prefix)/app || mkdir -m 0755 $(prefix)/app
test -d $(prefix)/static || mkdir -m 0755 $(prefix)/static
test -d $(prefix)/media || mkdir -m 0755 $(prefix)/media
# Install application code
cp $(app_dir)/manage.py $(prefix)/app
cp -R $(app_dir)/web_reflectivity $(prefix)/app
cp -R $(app_dir)/templates $(prefix)/app
cp -R $(app_dir)/fitting $(prefix)/app
cp -R $(app_dir)/datahandler $(prefix)/app
cp -R $(app_dir)/users $(prefix)/app
cp -R $(app_dir)/tools $(prefix)/app
cp -R $(app_dir)/static $(prefix)/app
# Copy test data for automated build/tests
cp -R test/test_data.txt $(prefix)/app
webapp: webapp/core
# Collect the static files and install them
cd $(prefix)/app; python manage.py collectstatic --noinput
# Create migrations and apply them
cd $(prefix)/app; python manage.py makemigrations
cd $(prefix)/app; python manage.py migrate
# Prepare web monitor cache: RUN THIS ONCE BY HAND
#cd $(prefix)/app; python manage.py createcachetable webcache
@echo "\n\nReady to go: run apachectl restart\n"
first_install: webapp/core
# Modify and copy the wsgi configuration
cp apache/apache_django_wsgi.conf /etc/httpd/conf.d
start:
apachectl restart
/sbin/service redis restart
/sbin/service celery restart
create_app_dir:
# Create deploy directory as root since it's in /var/www
test -d $(prefix) || sudo mkdir -m 0755 -p $(prefix); sudo chown $(shell whoami) $(prefix);
start_test_server:
redis-server
cd $(prefix)/app; celery -A fitting.celery worker --loglevel=debug
cd $(prefix)/app; python manage.py runserver
test:
cd $(prefix)/app; python manage.py test
.PHONY: start
.PHONY: check
.PHONY: install
.PHONY: webapp
.PHONY: webapp/core
.PHONY: first_install
.PHONY: test
.PHONY: create_app_dir
.PHONY: start_test_server