-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy_my_functions.sh
executable file
·98 lines (87 loc) · 3.35 KB
/
deploy_my_functions.sh
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
#! /bin/bash
DEV=false
SERVER=false
CACHE=true
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-s|--server)
SERVER=true
shift # past argument
;;
--no-cache)
CACHE=false
shift # past argument
;;
*) # unknown option
print >&2 "Usage: $0 [-d|--development-mode] [-s|--sample-functions] "
exit 1;;
#: ) echo "Missing option argument for -$OPTARG" >&2;
#exit 1;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# CREATING SYMLINKS FOR DEV
echo Creating symlinks for sample-functions
rm ./sample-functions/func_light/my_rig_config.json
rm ./sample-functions/func_heavy/my_rig_config.json
rm ./sample-functions/func_super_heavy/my_rig_config.json
rm ./sample-functions/func_obese_heavy/my_rig_config.json
ln -s ../../my_rig_config.json ./sample-functions/func_light/my_rig_config.json
ln -s ../../my_rig_config.json ./sample-functions/func_heavy/my_rig_config.json
ln -s ../../my_rig_config.json ./sample-functions/func_super_heavy/my_rig_config.json
ln -s ../../my_rig_config.json ./sample-functions/func_obese_heavy/my_rig_config.json
echo Creating symlinks for proxy functions
rm ./proxy/proxy/my_functions.json
rm ./proxy/proxy/my_rig_config.json
rm ./proxy/weight_scale/my_functions.json
rm ./proxy/weight_scale/my_rig_config.json
rm ./proxy/insert_duration/my_functions.json
rm ./proxy/insert_duration/my_rig_config.json
rm ./proxy/get_duration/my_functions.json
rm ./proxy/get_duration/my_rig_config.json
ln -s ../../my_rig_config.json ./proxy/proxy/my_rig_config.json
ln -s ../../.config/my_functions.json ./proxy/proxy/my_functions.json
ln -s ../../my_rig_config.json ./proxy/weight_scale/my_rig_config.json
ln -s ../../.config/my_functions.json ./proxy/weight_scale/my_functions.json
ln -s ../../my_rig_config.json ./proxy/insert_duration/my_rig_config.json
ln -s ../../.config/my_functions.json ./proxy/insert_duration/my_functions.json
ln -s ../../my_rig_config.json ./proxy/get_duration/my_rig_config.json
ln -s ../../.config/my_functions.json ./proxy/get_duration/my_functions.json
ln -s ../../my_rig_config.json ./proxy/get_overall_stats/my_rig_config.json
ln -s ../../.config/my_functions.json ./proxy/get_overall_stats/my_functions.json
#BUILD FUNCTIONS
if [ "$CACHE" = true ];
then
sudo faas-cli build -f ./sample-functions/stack.yml
else
sudo faas-cli build -f ./sample-functions/stack.yml --no-cache
fi
if [ "$SERVER" = false ];
then
if [ "$CACHE" = true ];
then
sudo faas-cli build -f proxy/proxy.yml
sudo faas-cli build -f proxy/weight_scale.yml
sudo faas-cli build -f proxy/insert_duration.yml
sudo faas-cli build -f proxy/get_duration.yml
sudo faas-cli build -f proxy/get_overall_stats.yml
else
sudo faas-cli build -f proxy/proxy.yml --no-cache
sudo faas-cli build -f proxy/weight_scale.yml --no-cache
sudo faas-cli build -f proxy/insert_duration.yml --no-cache
sudo faas-cli build -f proxy/get_duration.yml --no-cache
sudo faas-cli build -f proxy/get_overall_stats.yml --no-cache
fi
fi
#DEPLOY FUNCTIONS
faas-cli deploy -f ./sample-functions/stack.yml
if [ "$SERVER" = false ];
then
faas-cli deploy -f proxy/proxy.yml
faas-cli deploy -f proxy/weight_scale.yml
faas-cli deploy -f proxy/insert_duration.yml
faas-cli deploy -f proxy/get_duration.yml
faas-cli deploy -f proxy/get_overall_stats.yml
fi