forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-homepage
executable file
·126 lines (92 loc) · 3.65 KB
/
build-homepage
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
#!/usr/bin/env bash
# This script is sourced on build server, shebang is for convenience
# bash is used to have a predictable ulimit behavior
#
# @tags build
set -e
set -x
# remember the build directory
ROOT_DIR=$PWD
# build the applications
rm -rf build && mkdir -p build && cd build
# concrete install location is configurable
if [ -z "${INSTALL_PATH}" ]; then
INSTALL_PATH="/usr/local/elektra_backend"
fi
C_FLAGS='-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-protector-strong -Wstack-protector -fPIE -pie'
LD_FLAGS='-Wl,-z,now -Wl,-z,relro'
cmake -DENABLE_ASAN=ON -DBUILD_FULL=OFF -DBUILD_SHARED=ON -DBUILD_STATIC=OFF -DBUILD_DOCUMENTATION=OFF \
-DCMAKE_INSTALL_PREFIX="${INSTALL_PATH}" \
-DPLUGINS='ALL;-EXPERIMENTAL;-fstab;-ruby;-lua;-python;-xerces;-yamlcpp;-python2;file;camel;-dbus' \
-DTOOLS='kdb;rest-backend;rest-frontend' \
-DCMAKE_C_FLAGS="$C_FLAGS" \
-DCMAKE_CXX_FLAGS="$C_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
..
make -j 3
# run tests (exclude tests which write in system paths)
make run_nokdbtests
# rotate backup of previous website
rm -rf ${INSTALL_PATH}/share/elektra/tool_data_backup
cp -ra ${INSTALL_PATH}/share/elektra/tool_data ${INSTALL_PATH}/share/elektra/tool_data_backup
# cleanup old installed libraries (might have plugin we do not want any more or cause problems)
rm -rf ${INSTALL_PATH}/lib/*
# if tests were ok, we can install
make install
# use installed binaries and libs
export PATH=${INSTALL_PATH}/bin:${PATH}
export LD_LIBRARY_PATH=${INSTALL_PATH}/lib:${INSTALL_PATH}/lib/elektra
# now lets first output some version information for the build log
kdb --version
# print key database for debugging
#kdb export / simpleini
# prevent jenkins from killing daemons
BUILD_ID=dontKillMe
# allow core dumps
ulimit -c unlimited
# place for core dumps (name by: echo "core_%t_%p" > /proc/sys/kernel/core_pattern)
cd ${INSTALL_PATH}
PID_FILE=$(kdb sget /sw/elektra/restbackend/#0/current/cppcms/daemon/lock /run/elektra-rest-backend.pid)
ps -ef
printf "Old PID was: "
cat ${PID_FILE} || /bin/true
echo
IP=$(kdb sget /sw/elektra/restbackend/#0/current/cppcms/service/ip 127.0.0.1)
PORT=$(kdb sget /sw/elektra/restbackend/#0/current/cppcms/service/port 8080)
echo "The backend should running on $IP:$PORT"
netstat -tlpen
# then start the backend; succeed if it was not started before..
kdb stop-rest-backend || /bin/true
# cleanup /tmp files from build
find /tmp -mindepth 1 -user $(id -u) -delete || true
# avoid 'address already in use'
while netstat -tlpen | grep "$IP:$PORT"; do
sleep 1 # keep waiting (=downtime) short
done
# ensure daemon mode is enabled, otherwise script will be blocked
kdb set '/sw/elektra/restbackend/#0/current/cppcms/daemon/enable' '1'
# now start again
kdb run-rest-backend
printf "New PID is: "
cat ${PID_FILE} || /bin/true
echo
netstat -tlpen
# and finally re-compile the frontend
# - the old frontend is still alive and does not get taken offline (not necessary)
# - the configuration script does also take care of deleting old files,
# every configuration run will first clean the deployment directory and copy
# required files afterwards, ensuring an always up-to-date deployment
kdb build-rest-frontend
ELEKTRA_VERSION=$(kdb get --no-newline system/elektra/version/constants/KDB_VERSION)
API_DOC_DIR="${ROOT_DIR}/build/API_DOC/restapi/${ELEKTRA_VERSION}"
mkdir -p ${API_DOC_DIR}
# create and copy api description
apiary preview --path=$ROOT_DIR/doc/api_blueprints/snippet-sharing.apib --output=${API_DOC_DIR}/snippet-sharing.html
cp $ROOT_DIR/doc/api_blueprints/snippet-sharing.apib ${API_DOC_DIR}/snippet-sharing.apib
(
cd ${API_DOC_DIR}/..
rm -f current
ln -s $ELEKTRA_VERSION current
)
ps -ef
ulimit -a