Skip to content

Commit

Permalink
Add OpenSearch parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
d-stefanovic committed Apr 19, 2024
1 parent d13091f commit 3219e81
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
12 changes: 7 additions & 5 deletions sem-service
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,12 @@ service::start_elasticsearch() {
}

service::start_opensearch() {
service_version="${1:-2}"
service_version=$1
local service_image="${registry_host}/opensearch"

docker_cmd=$(echo "$2"|base64 -d )
service::pull_image "$service_image:$service_version"
docker_output=$(docker run --net=host --rm --name opensearch -e "discovery.type=single-node" -d "$service_image":"$service_version")
docker_output=$(bash -c "$docker_cmd $service_image:$service_version")
# run only if previous command exited successfully
docker_status=$(sem-dockerize 9200 opensearch)
if [ "$docker_status" == "0" ]; then
Expand Down Expand Up @@ -348,9 +349,9 @@ service::start() {
;;
"opensearch" )
shift
service_version="${service_version:-2}"
service::check_version 'opensearch' "${service_version%% *}"
service::duration service::start_opensearch "${service_version}" total "${service_name}"
IFS=" " read -r -a version_and_args <<< "$(sem-service-check-params opensearch "$@")"
service::check_version 'opensearch' "${version_and_args[0]}"
service::duration service::start_opensearch "${version_and_args[@]}" total "${service_name}"
exit 0
;;
"rabbitmq" )
Expand Down Expand Up @@ -506,6 +507,7 @@ service::print_usage() {
echo "memcached (default: 1.5), available versions: ${sem_services['memcached']}"
echo "mongodb (default: 4.1), available versions: ${sem_services['mongo']}"
echo "elasticsearch (default: 6.5), available versions: ${sem_services['elasticsearch']}"
echo "opensearch (default: 2), available versions: ${sem_services['opensearch']}"
echo "cassandra (default: 3.11), available versions: ${sem_services['cassandra']}"
echo "rethinkdb (default: 2.3), available versions: ${sem_services['rethinkdb']}"
}
Expand Down
17 changes: 17 additions & 0 deletions sem-service-check-params
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@ params-check::elasticsearch () {
echo "$service_version $default_params"
}

params-check::opensearch () {
local defaultEnv="-e 'discovery.type=single-node'"

service_version="2"
if [ "${1:0:1}" != "-" ];then
service_version="${1:-$service_version}"
shift
fi
defaultEnv="$defaultEnv $*"
default_params=$(echo "docker run --net=host --rm --name opensearch -d $defaultEnv "|base64 --wrap=0)
echo "$service_version $default_params"
}

params-check::main () {
case "$1" in
"mysql" )
Expand All @@ -212,6 +225,10 @@ params-check::main () {
shift
params-check::elasticsearch $@
;;
"opensearch" )
shift
params-check::opensearch $@
;;
* )
shift
echo "$@"
Expand Down

0 comments on commit 3219e81

Please sign in to comment.