-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_apis
More file actions
executable file
·52 lines (38 loc) · 1 KB
/
start_apis
File metadata and controls
executable file
·52 lines (38 loc) · 1 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
52
#!/bin/sh
su nodejs -c "forever stopall"
echo making sure the db rights are alright
./add_db_user
while read -a line
do
export line
if [ ${#line[@]} -gt 6 ]
then
api_port=${line[6]#*=}
api_name=$(echo ${line[0]} | sed "s/\//-/g" | cut -c2-)
## check if api folder exists
dir=/opt/lqfb/api-instances/$api_name
if [ ! -d $dir ]
then
echo Creating directory $dir
cp -r /opt/lqfb/lfapi $dir
# write config
cat > $dir/config.js << EOF
exports.bind_address = '127.0.0.1';
exports.bind_port = $api_port;
exports.public_access_level = 'anonymous';
exports.connectionString = 'pg://localhost/${line[1]}';
exports.public_url_path = 'http://api-$api_name.lqpp.de/';
exports.mail = {
from: 'LQFB <support@lqpp.de>',
subject_prefix: '[lfapi] '
};
exports.settings = {
result_row_limit: { max: 1001, default: 101 }
}
EOF
fi
echo Staring api-$api_name on Port $api_port
cd $dir
su nodejs -c "forever start lfapi.js"
fi
done < /opt/lqfb/instances