Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dist): add deploy-release.sh to download & start services #330

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions dist/deploy-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Download hugegraph-server and hugegraph-toolcahain, then start them:
# hugegraph-server and hugegraph-hubble

set -e

RELEASE_VERSION=$1 # like 1.2.0
RELEASE_VERSION=${RELEASE_VERSION:?"Please input the release version, like 1.2.0"}
imbajin marked this conversation as resolved.
Show resolved Hide resolved

DOWNLOAD_URL_PREFIX="https://downloads.apache.org/incubator/hugegraph"
SERVER_TAR="apache-hugegraph-incubating-${RELEASE_VERSION}.tar.gz"
TOOLCHAIN_TAR="apache-hugegraph-toolchain-incubating-${RELEASE_VERSION}.tar.gz"

echo "download hugegraph tars from $DOWNLOAD_URL_PREFIX..."
if [[ ! -f "${SERVER_TAR}" ]]; then
wget "${DOWNLOAD_URL_PREFIX}/${RELEASE_VERSION}/${SERVER_TAR}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note wget is not bind in mac or some linux env, better use curl first(instead)

could refer here:
https://github.com/apache/incubator-hugegraph/blob/d0f63c8ac3c0b835560e37404b7b9e271ac0f678/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh#L278

function download() {
    local path=$1
    local download_url=$2
    if command_available "curl"; then
        if [ ! -d "$path" ]; then
            mkdir -p "$path" || {
                echo "Failed to create directory: $path"
                exit 1
            }
        fi
        curl -L "${download_url}" -o "${path}/$(basename "${download_url}")"
    elif command_available "wget"; then
        wget --help | grep -q '\--show-progress' && progress_opt="-q --show-progress" || progress_opt=""
        wget "${download_url}" -P "${path}" $progress_opt
    else
        echo "Required curl or wget but they are unavailable"
        exit 1
    fi
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok let's introduce util.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but there is a problem, we need to download 2 files after util.sh introduction, which is not convenient.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but there is a problem, we need to download 2 files after util.sh introduction, which is not convenient.

Maybe just copy the function directly? (no need to add the whole script file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it also needs to copy download and command_available, copied code is difficult to maintain, so we prefer to keep it simple

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also download the corresponding SHA512 file for integrity checking and provide a basis for skipping the download of existing tar packages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal here is just to provide an automated deployment script for developers, so I hope to keep it simple.

tar -xzvf "${SERVER_TAR}"
fi
if [[ ! -f "${TOOLCHAIN_TAR}" ]]; then
wget "${DOWNLOAD_URL_PREFIX}/${RELEASE_VERSION}/${TOOLCHAIN_TAR}"
tar -xzvf ${TOOLCHAIN_TAR}
fi

echo "start hugegraph-server..."
cd ./*hugegraph-incubating*${RELEASE_VERSION}
bin/init-store.sh
sleep 3
bin/start-hugegraph.sh
cd ..

echo "start hugegraph-hubble..."
cd ./*toolchain*${RELEASE_VERSION}/*hubble*${RELEASE_VERSION}
bin/start-hubble.sh
Loading