-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
52 lines (42 loc) · 1.74 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
# https://www.gnu.org/software/make/manual/html_node/Special-Variables.html
# https://ftp.gnu.org/old-gnu/Manuals/make-3.80/html_node/make_17.html
PROJECT_MKFILE_PATH := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
PROJECT_MKFILE_DIR := $(shell cd $(shell dirname $(PROJECT_MKFILE_PATH)); pwd)
PROJECT_LOCAL := ${LOCAL_DATA}
include $(PROJECT_MKFILE_DIR)/postgres/Makefile
AIRFLOW_WEBSERVER_PORT=3333
AIRFLOW_SCHEDULER_PIDFILE=$(PROJECT_LOCAL)/airflow-scheduler.pid
AIRFLOW_WEBSERVER_PIDFILE=$(PROJECT_LOCAL)/airflow-webserver.pid
init:
$(MAKE) postgres-init
$(MAKE) airflow-init
airflow-init:
airflow initdb
airflow-start:
$(MAKE) postgres-start
# https://stackoverflow.com/a/61633778
airflow webserver -p $(AIRFLOW_WEBSERVER_PORT) \
--daemon \
--pid $(AIRFLOW_WEBSERVER_PIDFILE) \
--access_logfile $(AIRFLOW__WEBSERVER__ACCESS_LOGFILE) \
--stdout $(AIRFLOW__WEBSERVER__ACCESS_LOGFILE) \
--log-file $(AIRFLOW__WEBSERVER__ACCESS_LOGFILE) \
--error_logfile $(AIRFLOW__WEBSERVER__ERROR_LOGFILE) \
--stderr $(AIRFLOW__WEBSERVER__ERROR_LOGFILE)
airflow scheduler --daemon --pid $(AIRFLOW_SCHEDULER_PIDFILE) \
--stdout $(AIRFLOW__SCHEDULER__ACCESS_LOGFILE) \
--log-file $(AIRFLOW__SCHEDULER__ACCESS_LOGFILE) \
--stderr $(AIRFLOW__SCHEDULER__ERROR_LOGFILE)
airflow-stop:
@echo "Stopping Airflow gracefully..."
@if [ -f "$(AIRFLOW_SCHEDULER_PIDFILE)" ]; then cat $(AIRFLOW_SCHEDULER_PIDFILE) | xargs kill -s TERM; fi;
@if ! [ -z "$(shell lsof -nti:$(AIRFLOW_WEBSERVER_PORT))" ]; then kill -s TERM $(shell lsof -nti:$(AIRFLOW_WEBSERVER_PORT)); fi;
$(MAKE) postgres-stop
@echo "Done."
typecheck:
poetry run mypy -p nix-airflow-template
reset:
$(MAKE) airflow-stop
$(MAKE) postgres-purge
rm -rvf $(PROJECT_LOCAL)/logs
$(MAKE) init