Skip to content

Commit

Permalink
815
Browse files Browse the repository at this point in the history
Signed-off-by: hanzhixiao <709674996@qq.com>
  • Loading branch information
hanzhixiao committed Aug 11, 2023
1 parent 71393da commit 3ef64e9
Show file tree
Hide file tree
Showing 9 changed files with 405 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build Stage
FROM golang:1.21 AS builder
FROM golang:1.20 AS builder

# Set go mod installation source and proxy
ARG GO111MODULE=on
Expand All @@ -10,8 +10,8 @@ ENV GOPROXY=$GOPROXY
# Set up the working directory
WORKDIR /openim/openim-server

COPY go.mod go.sum ./
RUN go mod download
COPY go.mod go.sum go.work go.work.sum ./
#RUN go mod download

# Copy all files to the container
ADD . .
Expand All @@ -27,5 +27,6 @@ WORKDIR ${SERVER_WORKDIR}
COPY --from=builder ${OPENIM_SERVER_CMDDIR} /openim/openim-server/scripts
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
COPY --from=builder ${SERVER_WORKDIR}/_output/bin/platforms /openim/openim-server/_output/bin/platforms
COPY --from=builder ${SERVER_WORKDIR}/_output/bin-tools/platforms /openim/openim-server/_output/bin-tools/platforms

CMD ["bash","-c","${OPENIM_SERVER_CMDDIR}/docker_start_all.sh"]
5 changes: 3 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ services:

openim-server:
image: ghcr.io/openimsdk/openim-server:latest
# build: .
container_name: openim-server
volumes:
- ./logs:/openim/openim-server/logs
Expand Down Expand Up @@ -149,7 +150,7 @@ services:
# ports:
# - 9091:9091
depends_on:
- openim-server
- openim-server
command: --web.listen-address=:9091 --config.file="/etc/prometheus/prometheus.yml"
network_mode: "host"

Expand All @@ -169,4 +170,4 @@ services:
# container_name: node-exporter
# restart: always
# ports:
# - "9100:9100"
# - "9100:9100"
3 changes: 2 additions & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
go 1.20

use (
.
.
./tools/component
./tools/infra
./tools/ncpu
)
9 changes: 9 additions & 0 deletions scripts/docker_start_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ need_to_start_server_shell=(
${SCRIPTS_ROOT}/start_cron.sh
)

component_check=start_component_check.sh
chmod +x $SCRIPTS_ROOT/$component_check
$SCRIPTS_ROOT/$component_check
if [ $? -ne 0 ]; then
# Print error message and exit
echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}"
exit -1
fi

#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started

sleep 10
Expand Down
20 changes: 19 additions & 1 deletion scripts/path_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ declare -A supported_architectures=(
["darwin-x86_64"]="_output/bin/platforms/darwin/amd64" # Alias for darwin-amd64
)

declare -A supported_architectures_tools=(
["linux-amd64"]="_output/bin-tools/platforms/linux/amd64"
["linux-arm64"]="_output/bin-tools/platforms/linux/arm64"
["linux-mips64"]="_output/bin-tools/platforms/linux/mips64"
["linux-mips64le"]="_output/bin-tools/platforms/linux/mips64le"
["linux-ppc64le"]="_output/bin-tools/platforms/linux/ppc64le"
["linux-s390x"]="_output/bin-tools/platforms/linux/s390x"
["darwin-amd64"]="_output/bin-tools/platforms/darwin/amd64"
["windows-amd64"]="_output/bin-tools/platforms/windows/amd64"
["linux-x86_64"]="_output/bin-tools/platforms/linux/amd64" # Alias for linux-amd64
["darwin-x86_64"]="_output/bin-tools/platforms/darwin/amd64" # Alias for darwin-amd64
)

# Check if the architecture and version are supported
if [[ -z ${supported_architectures["$version-$architecture"]} ]]; then
echo -e "${BLUE_PREFIX}================> Unsupported architecture: $architecture or version: $version${COLOR_SUFFIX}"
Expand All @@ -50,6 +63,7 @@ echo -e "${BLUE_PREFIX}================> Architecture: $architecture${COLOR_SUFF

# Set the BIN_DIR based on the architecture and version
BIN_DIR=${supported_architectures["$version-$architecture"]}
BIN_DIR_TOOLS=${supported_architectures_tools["$version-$architecture"]}

echo -e "${BLUE_PREFIX}================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR${COLOR_SUFFIX}"

Expand Down Expand Up @@ -84,6 +98,10 @@ config_path="$OPENIM_ROOT/config/config.yaml"
configfile_path="$OPENIM_ROOT/config"
log_path="$OPENIM_ROOT/log"


component_check="component"
component_check_binary_root="$OPENIM_ROOT/$BIN_DIR_TOOLS"

# servicefile dir path
service_source_root=(
# api service file
Expand Down Expand Up @@ -120,4 +138,4 @@ service_names=(
"${msg_name}"
"${push_name}"
# "${sdk_server_name}"
)
)
13 changes: 13 additions & 0 deletions scripts/start_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ need_to_start_server_shell=(
start_cron.sh
)

component_check=start_component_check.sh
echo -e ""
chmod +x $component_check
echo -e "=========> ${BACKGROUND_GREEN}Executing ${component_check}...${COLOR_SUFFIX}"
echo -e ""
./$component_check
if [ $? -ne 0 ]; then
# Print error message and exit
echo -e "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}"
exit -1
fi


# Loop through the script names and execute them
for i in ${need_to_start_server_shell[*]}; do
chmod +x $i
Expand Down
42 changes: 42 additions & 0 deletions scripts/start_component_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed 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.

#Include shell font styles and some basic information
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..

#Include shell font styles and some basic information
source $SCRIPTS_ROOT/style_info.sh
source $SCRIPTS_ROOT/path_info.sh
source $SCRIPTS_ROOT/function.sh

echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"

bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"

cd ${component_check_binary_root}
echo -e "${YELLOW_PREFIX}=======>$PWD${COLOR_SUFFIX}"
cmd="./${component_check}"
echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log
$cmd

if [ $? -ne 0 ]; then
exit 1
fi


3 changes: 3 additions & 0 deletions tools/component/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/OpenIMSDK/Open-IM-Server/tools/component

go 1.19
Loading

0 comments on commit 3ef64e9

Please sign in to comment.