-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (41 loc) Β· 1.9 KB
/
Copy pathMakefile
File metadata and controls
51 lines (41 loc) Β· 1.9 KB
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
PY := .venv/bin/python
.PHONY: init-db run-once pause resume chat-id print-crontab \
install-service uninstall-service test
init-db:
$(PY) -c "from src import db; c = db.connect(); db.init_db(c); print('db ready')"
run-once:
$(PY) -m src.ingest --once --tier fast
$(PY) -m src.ingest --once --tier press
$(PY) -m src.ingest --once --tier daily
$(PY) -m src.cluster --once
$(PY) -m src.score --once
$(PY) -m src.compose --once
$(PY) -m src.deliver --once
pause:
mkdir -p data && touch data/PAUSED && echo "paused"
resume:
rm -f data/PAUSED && echo "resumed"
chat-id:
$(PY) -c "import os, requests; from dotenv import load_dotenv; \
load_dotenv(); t = os.environ['TELEGRAM_BOT_TOKEN']; \
r = requests.get(f'https://api.telegram.org/bot{t}/getUpdates', timeout=15).json(); \
ids = {str(u['message']['chat']['id']) for u in r.get('result', []) if 'message' in u}; \
print('chat id(s):', ', '.join(ids) if ids else 'none β message your bot first')"
print-crontab:
@echo "# tech-digest crontab (all times local; degraded mode β prefer systemd)"
@echo "*/30 * * * * cd $(CURDIR) && $(PY) -m src.ingest --once --tier fast && $(PY) -m src.cluster --once && $(PY) -m src.score --once"
@echo "0 */2 * * * cd $(CURDIR) && $(PY) -m src.ingest --once --tier press"
@echo "30 5 * * * cd $(CURDIR) && $(PY) -m src.ingest --once --tier daily"
@echo "15 6 * * * cd $(CURDIR) && $(PY) -m src.compose --once"
@echo "30 6 * * * cd $(CURDIR) && $(PY) -m src.deliver --once"
install-service:
sed -e "s|__WORKDIR__|$(CURDIR)|g" -e "s|__USER__|$(USER)|g" \
deploy/tech-digest.service | sudo tee /etc/systemd/system/tech-digest.service > /dev/null
sudo systemctl daemon-reload
@echo "installed β enable with: sudo systemctl enable --now tech-digest"
uninstall-service:
sudo systemctl disable --now tech-digest || true
sudo rm -f /etc/systemd/system/tech-digest.service
sudo systemctl daemon-reload
test:
$(PY) -m pytest