jonathanjordan21 commited on
Commit
973a20c
·
verified ·
1 Parent(s): 166d06d

Create standalone_embed.sh

Browse files
Files changed (1) hide show
  1. standalone_embed.sh +169 -0
standalone_embed.sh ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ # Licensed to the LF AI & Data foundation under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ run_embed() {
20
+ cat << EOF > embedEtcd.yaml
21
+ listen-client-urls: http://0.0.0.0:2379
22
+ advertise-client-urls: http://0.0.0.0:2379
23
+ quota-backend-bytes: 4294967296
24
+ auto-compaction-mode: revision
25
+ auto-compaction-retention: '1000'
26
+ EOF
27
+
28
+ cat << EOF > user.yaml
29
+ # Extra config to override default milvus.yaml
30
+ EOF
31
+
32
+ sudo docker run -d \
33
+ --name milvus-standalone \
34
+ --security-opt seccomp:unconfined \
35
+ -e ETCD_USE_EMBED=true \
36
+ -e ETCD_DATA_DIR=/var/lib/milvus/etcd \
37
+ -e ETCD_CONFIG_PATH=/milvus/configs/embedEtcd.yaml \
38
+ -e COMMON_STORAGETYPE=local \
39
+ -v $(pwd)/volumes/milvus:/var/lib/milvus \
40
+ -v $(pwd)/embedEtcd.yaml:/milvus/configs/embedEtcd.yaml \
41
+ -v $(pwd)/user.yaml:/milvus/configs/user.yaml \
42
+ -p 19530:19530 \
43
+ -p 9091:9091 \
44
+ -p 2379:2379 \
45
+ --health-cmd="curl -f http://localhost:9091/healthz" \
46
+ --health-interval=30s \
47
+ --health-start-period=90s \
48
+ --health-timeout=20s \
49
+ --health-retries=3 \
50
+ milvusdb/milvus:v2.4.15 \
51
+ milvus run standalone 1> /dev/null
52
+ }
53
+
54
+ wait_for_milvus_running() {
55
+ echo "Wait for Milvus Starting..."
56
+ while true
57
+ do
58
+ res=`sudo docker ps|grep milvus-standalone|grep healthy|wc -l`
59
+ if [ $res -eq 1 ]
60
+ then
61
+ echo "Start successfully."
62
+ echo "To change the default Milvus configuration, add your settings to the user.yaml file and then restart the service."
63
+ break
64
+ fi
65
+ sleep 1
66
+ done
67
+ }
68
+
69
+ start() {
70
+ res=`sudo docker ps|grep milvus-standalone|grep healthy|wc -l`
71
+ if [ $res -eq 1 ]
72
+ then
73
+ echo "Milvus is running."
74
+ exit 0
75
+ fi
76
+
77
+ res=`sudo docker ps -a|grep milvus-standalone|wc -l`
78
+ if [ $res -eq 1 ]
79
+ then
80
+ sudo docker start milvus-standalone 1> /dev/null
81
+ else
82
+ run_embed
83
+ fi
84
+
85
+ if [ $? -ne 0 ]
86
+ then
87
+ echo "Start failed."
88
+ exit 1
89
+ fi
90
+
91
+ wait_for_milvus_running
92
+ }
93
+
94
+ stop() {
95
+ sudo docker stop milvus-standalone 1> /dev/null
96
+
97
+ if [ $? -ne 0 ]
98
+ then
99
+ echo "Stop failed."
100
+ exit 1
101
+ fi
102
+ echo "Stop successfully."
103
+
104
+ }
105
+
106
+ delete_container() {
107
+ res=`sudo docker ps|grep milvus-standalone|wc -l`
108
+ if [ $res -eq 1 ]
109
+ then
110
+ echo "Please stop Milvus service before delete."
111
+ exit 1
112
+ fi
113
+ sudo docker rm milvus-standalone 1> /dev/null
114
+ if [ $? -ne 0 ]
115
+ then
116
+ echo "Delete milvus container failed."
117
+ exit 1
118
+ fi
119
+ echo "Delete milvus container successfully."
120
+ }
121
+
122
+ delete() {
123
+ delete_container
124
+ sudo rm -rf $(pwd)/volumes
125
+ sudo rm -rf $(pwd)/embedEtcd.yaml
126
+ sudo rm -rf $(pwd)/user.yaml
127
+ echo "Delete successfully."
128
+ }
129
+
130
+ upgrade() {
131
+ read -p "Please confirm if you'd like to proceed with the upgrade. The default will be to the latest version. Confirm with 'y' for yes or 'n' for no. > " check
132
+ if [ "$check" == "y" ] ||[ "$check" == "Y" ];then
133
+ res=`sudo docker ps -a|grep milvus-standalone|wc -l`
134
+ if [ $res -eq 1 ]
135
+ then
136
+ stop
137
+ delete_container
138
+ fi
139
+
140
+ curl -sfL https://raw.githubusercontent.com/milvus-io/milvus/master/scripts/standalone_embed.sh -o standalone_embed_latest.sh && \
141
+ bash standalone_embed_latest.sh start 1> /dev/null && \
142
+ echo "Upgrade successfully."
143
+ else
144
+ echo "Exit upgrade"
145
+ exit 0
146
+ fi
147
+ }
148
+
149
+ case $1 in
150
+ restart)
151
+ stop
152
+ start
153
+ ;;
154
+ start)
155
+ start
156
+ ;;
157
+ stop)
158
+ stop
159
+ ;;
160
+ upgrade)
161
+ upgrade
162
+ ;;
163
+ delete)
164
+ delete
165
+ ;;
166
+ *)
167
+ echo "please use bash standalone_embed.sh restart|start|stop|upgrade|delete"
168
+ ;;
169
+ esac