[Perl] DAQ system for the FAPG.
perf compress JSON responses with nginx
- install a dashboard nginx gzip MIME configuration - include nginx in dashboard deployment dependencies - validate, enable, and reload nginx during deployment
roles/dashboard/deploy
@@ -9,6 +9,8 @@
9
9
10
10
readonly SERVICE_NAME="fapg-daq-dashboard.service"
11
11
readonly SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}"
12
Added:
readonly NGINX_GZIP_SOURCE="${SCRIPT_DIR}/etc/nginx/conf.d/fapg-daq-dashboard-gzip.conf"
13
Added:
readonly NGINX_GZIP_FILE="/etc/nginx/conf.d/fapg-daq-dashboard-gzip.conf"
12
14
13
15
readonly STATE_DIR="/var/lib/fapg-daq"
14
16
readonly RUN_USER="fapg-daq"
@@ -29,6 +31,7 @@
29
31
apt-get update
30
32
apt-get install -y \
31
33
perl \
34
Added:
nginx \
32
35
libdbd-sqlite3-perl \
33
36
libmojolicious-perl \
34
37
libmojo-sqlite-perl
@@ -56,6 +59,7 @@
56
59
function check_repo_layout() {
57
60
[[ -d "${REPO_DIR}" ]] || die "Repo not found at ${REPO_DIR}."
58
61
[[ -f "${DASHBOARD_SCRIPT}" ]] || die "${DASHBOARD_SCRIPT} does not exist."
62
Added:
[[ -f "${NGINX_GZIP_SOURCE}" ]] || die "${NGINX_GZIP_SOURCE} does not exist."
59
63
}
60
64
61
65
function write_systemd_service() {
@@ -64,6 +68,16 @@
64
68
"${SERVICE_FILE}"
65
69
}
66
70
71
Added:
function configure_nginx_compression() {
72
Added:
install -m 0644 -o root -g root \
73
Added:
"${NGINX_GZIP_SOURCE}" \
74
Added:
"${NGINX_GZIP_FILE}"
75
Added:
76
Added:
nginx -t
77
Added:
systemctl enable --now nginx
78
Added:
systemctl reload nginx
79
Added:
}
80
Added:
67
81
function enable_service() {
68
82
systemctl daemon-reload
69
83
systemctl enable "${SERVICE_NAME}"
@@ -84,6 +98,7 @@
84
98
create_runtime_user
85
99
check_repo_layout
86
100
write_systemd_service
101
Added:
configure_nginx_compression
87
102
enable_service
88
103
show_status
89
104
}
roles/dashboard/etc/nginx/conf.d/fapg-daq-dashboard-gzip.conf
@@ -0,0 +1,3 @@
1
Added:
# Debian's nginx configuration enables gzip in the http context. Extend the
2
Added:
# compressed MIME types to cover the dashboard API responses.
3
Added:
gzip_types application/json application/problem+json application/vnd.api+json;