-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconf.mk
88 lines (74 loc) · 3 KB
/
conf.mk
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
# The full project path
PROJECT_PATH ?= $(shell git rev-parse --show-toplevel)
# The project directory name
PROJECT_NAME ?= $(notdir $(PROJECT_PATH))
include $(PROJECT_PATH)/local-conf.mk
# Project mode, development/production
PROJECT_MODE ?= development
# Set PROJECT_REV from a tag on head, or if that fails (branch):(sha)
PROJECT_REV = $(shell git describe --exact-match HEAD 2>/dev/null || true)
ifeq ($(PROJECT_REV),)
PROJECT_REV = $(shell git rev-parse --abbrev-ref HEAD):$(shell git rev-parse --short HEAD)
endif
###################
# Configuration options for serving client
# NGINX's server_name. Multiple space-separated values are allowed
WWW_SERVER_NAME ?= $(shell hostname --fqdn)
WWW_SERVER_ALIASES ?=
ifeq ($(PROJECT_MODE),development)
WWW_UWSGI_CACHE_ZONE ?= off
else
WWW_UWSGI_CACHE_ZONE ?= api_cache
endif
WWW_CERT_PATH ?= /var/lib/dehydrated
WWW_UWSGI_TIMEOUT ?= 5m
# Make a guess at branch name, since production instances will be detached HEAD
WWW_RTD_BASE_URL ?= https://clic.readthedocs.io/en/$(shell git describe --abbrev=0 | grep -oE '[0-9]+\.[0-9]+')
###################
# Configuration options for running API server
API_SERVICE_FILE ?= /etc/systemd/system/$(PROJECT_NAME).service
ifeq ($(PROJECT_MODE),development)
# Default to user that checked out code (i.e the developer)
API_USER ?= $(shell stat -c '%U' $(PROJECT_PATH)/.git)
API_GROUP ?= $(shell stat -c '%U' $(PROJECT_PATH)/.git)
API_SOCKET ?= /tmp/$(PROJECT_NAME)_uwsgi.$(PROJECT_MODE).sock
else
# Assume we're using a systemd DynamicUser
API_USER ?= $(PROJECT_NAME)
API_GROUP ?= $(PROJECT_NAME)
# NB: This should be created by RuntimeDirectory
API_SOCKET ?= /run/$(PROJECT_NAME)/uwsgi.$(PROJECT_MODE).sock
endif
API_UWSGI_PROCESSES ?= 4
API_UWSGI_THREADS ?= 4
API_UWSGI_HARAKIRI ?= 0
API_UWSGI_CACHE_SIZE ?= 1g
###################
# DB configuration options
# The user that has root access to DB
DB_SUDO_USER ?= postgres
# The hostname / socket path to connect to
DB_HOST ?= /var/run/postgresql/
# The DB to create
DB_NAME ?= $(shell echo -n $(PROJECT_NAME) | sed 's/\W/_/g')_db
# The credentials that the app will use
DB_USER ?= $(API_USER)
DB_PASS ?=
# An alternative user, generally the installing user used for running import script
DB_ALT_USER ?= $(shell stat -c '%U' $(PROJECT_PATH)/.git)
DB_ALT_PASS ?=
# The location of a postgres config we can use
DB_CONF_FILE ?= $(shell ls -d1 /etc/postgresql/*/main/conf.d/ | sort | tail -1)${DB_NAME}.conf
# The amount of memory which can be used for sorts.
# 64MB handles the worst likely queries but will use potentially an extra 1G of server memory.
DB_CONF_WORK_MEM = 64MB
###################
# Anything depending on conf.mk should be rebuilt on commits / local-conf.mk changes
$(PROJECT_PATH)/conf.mk: \
$(PROJECT_PATH)/local-conf.mk \
../.git/logs/HEAD
touch $(PROJECT_PATH)/conf.mk
# Create empty local-conf.mk if it doesn't exist
$(PROJECT_PATH)/local-conf.mk:
[ -e $(PROJECT_PATH)/local-conf.mk ] || touch $(PROJECT_PATH)/local-conf.mk
.EXPORT_ALL_VARIABLES: