-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathsample_stop.sh
More file actions
executable file
·49 lines (40 loc) · 1.14 KB
/
sample_stop.sh
File metadata and controls
executable file
·49 lines (40 loc) · 1.14 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
#!/bin/bash
DLSPS_NODE_IP="localhost"
DLSPS_PORT=8080
function stop_all_pipelines() {
echo
echo -n ">>>>>Stopping all running pipelines."
status=$(curl -k -s -X GET "https://$DLSPS_NODE_IP/api/pipelines/status" -H "accept: application/json")
if [ $? -ne 0 ]; then
echo -e "\nError: curl -k command failed. Check the deployment status."
return 1
fi
pipelines=$(echo $status | grep -o '"id": "[^"]*"' | awk ' { print $2 } ' | tr -d \" | paste -sd ',' -)
IFS=','
for pipeline in $pipelines; do
response=$(curl -k -s --location -X DELETE "https://$DLSPS_NODE_IP/api/pipelines/${pipeline}")
sleep 2
done
unset IFS
running=true
while [ "$running" == true ]; do
echo -n "."
status=$(curl -k -s --location -X GET "https://$DLSPS_NODE_IP/api/pipelines/status" | grep state | awk ' { print $2 } ' | tr -d \")
if [[ "$status" == *"RUNNING"* ]]; then
running=true
sleep 2
else
running=false
fi
done
echo -n " done."
echo
return 0
}
stop_all_pipelines
if [ $? -ne 0 ]; then
exit 1
echo "Error: Check pipelines manually"
else
echo ">>>>>All running pipelines stopped."
fi