-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
143 lines (115 loc) · 4.58 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#
# Assuming: you have python poetry installed
# sudo apt install python3-poetry
#
# if poetry install takes too long
# export PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring
#
# yt-dlp needs to be callable from path https://github.com/yt-dlp/yt-dlp/wiki/Installation
#
.PHONY: install install-minimal
.PHONY: createtables createtables-minimal createtables-celery createsuperuser installsysdeps configuresysdeps
.PHONY: run run-celery run-server run-web-server run-minimal run-crawlee-server
.PHONY: update update-instances static migrate reformat oncommit test create-companion-app
.PHONY: clear clear-crawlee-files clear-celery backfiles
CP = cp
PROJECT_NAME = linklibrary
PORT=8080
APP_NAME = rsshistory
# Edit companion app if necessary
COMPANION_APP = catalog
# Assumptions:
# - python poetry is in your path
install:
poetry install
poetry run python -m spacy download en_core_web_sm
poetry run playwright install
@$(CP) $(PROJECT_NAME)/settings_template.py $(PROJECT_NAME)/settings.py
@echo "*******************************************************************"
@echo "Please configure your django application linklibrary in settings.py"
@echo "Please:"
@echo " - define SECRET_KEY settings.py"
@echo " - use createtables rule to create tables"
@echo " - add required hosts to ALLOWED_HOSTS"
@echo "*******************************************************************"
install-minimal:
poetry install
poetry run python -m spacy download en_core_web_sm
poetry run playwright install
@$(CP) $(PROJECT_NAME)/settings_template_minimal.py $(PROJECT_NAME)/settings.py
@echo "*******************************************************************"
@echo "Please configure your django application linklibrary in settings.py"
@echo "Please:"
@echo " - define SECRET_KEY settings.py"
@echo " - use createtables rule to create tables"
@echo " - add required hosts to ALLOWED_HOSTS"
@echo "*******************************************************************"
createtables: createtables-minimal createtables-celery
createtables-minimal:
poetry run python manage.py migrate --run-syncdb
createtables-celery:
poetry run python manage.py migrate django_celery_results
createsuperuser:
poetry run python manage.py createsuperuser
# Assumptions:
# - I cannot write installation commands for each Linux distro. I assume you are using debian-derivative
# - assume you are using sudo for this command. solve it later https://github.com/rumca-js/Django-link-archive/issues/10
# http://pont.ist/rabbit-mq/
# xvfb is installed for full selenium to be operational
installsysdeps:
apt -y install rabbitmq-server memcached wget id3v2 chromium-chromedriver xvfb
systemctl enable rabbitmq-server
systemctl start rabbitmq-server
systemctl enable memcached.service
systemctl start memcached.service
run: run-server run-web-server
run-minimal: run-server
run-server: run-script-server run-celery
run-script-server:
rm -rf storage
poetry run python script_server.py &
run-celery:
rm -rf storage
rm -f celerybeat-schedule.db
# if we do not limit celery worker memory, then it will grow indefinitely
poetry run celery -A linklibrary beat -l INFO &
poetry run celery -A linklibrary worker -l INFO --concurrency=4 --max-memory-per-child=200000 &
run-web-server:
poetry run python manage.py runserver 0.0.0.0:$(PORT)
# Assumptions:
# - python black is in your path
# Black should use gitignore files to ignore refactoring
reformat:
poetry run black $(APP_NAME)
poetry run black utils
poetry run black webtools
static:
poetry run python -m manage collectstatic
migrations-check:
poetry run python -m manage makemigrations --check --dry-run
update-instances:
poetry run python3 workspace.py -U
migrate:
poetry run python manage.py makemigrations
poetry run python manage.py migrate
update: update-instances migrate static
test: migrations-check
@poetry run python manage.py test $(APP_NAME).tests -v 2
oncommit: reformat test
create-companion-app:
rm -rf ./$(COMPANION_APP)
mkdir $(COMPANION_APP)
cp -r $(APP_NAME)/* ./$(COMPANION_APP)/*
grep -rl $(APP_NAME) ./$(COMPANION_APP) | xargs sed -i 's/$(APP_NAME)/$(COMPANION_APP)/g'
@echo "*******************************************************************"
@echo "Please configure your django application linklibrary in settings.py"
@echo "Please:"
@echo " - register app in INSTALLED_APPS, add '$(COMPANION_APP).apps.LinkDatabase',
@echo "*******************************************************************"
clear: clear-celery clear-crawlee-files
clear-celery:
rm -f celerybeat-schedule.db
clear-crawlee-files:
rm -rf storage
backfiles:
find . -type f -name "*.bak" -exec rm -f {} +