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

fix: reconstruct the script of 'make start' 'make stop' and 'make check' #1953

Merged
merged 84 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
7077083
fix: del the error world
luhaoling Feb 22, 2024
5f71f27
fix: refactoring scripts
luhaoling Feb 22, 2024
84e916e
fix: del nounset
luhaoling Feb 22, 2024
b0bcbb6
rm set error
skiffer-git Feb 22, 2024
4f790aa
rm set error
skiffer-git Feb 22, 2024
27d88fd
replace openim::log::info
skiffer-git Feb 22, 2024
97191a1
replace openim::log::info
skiffer-git Feb 22, 2024
d24e8ba
replace openim::log::info
skiffer-git Feb 22, 2024
01d7a9c
log
skiffer-git Feb 22, 2024
b9d1037
log
skiffer-git Feb 22, 2024
a5dbbe0
log
skiffer-git Feb 22, 2024
bb15d14
log
skiffer-git Feb 22, 2024
812fa38
log
skiffer-git Feb 22, 2024
1993117
log
skiffer-git Feb 22, 2024
eee941e
log
skiffer-git Feb 22, 2024
92e7704
log
skiffer-git Feb 22, 2024
a6fbf52
log
skiffer-git Feb 22, 2024
3f19efa
log
skiffer-git Feb 22, 2024
b99ec42
log
skiffer-git Feb 22, 2024
8420de9
log
skiffer-git Feb 22, 2024
c38dff1
log
skiffer-git Feb 22, 2024
40a834a
log
skiffer-git Feb 22, 2024
c24f72d
log
skiffer-git Feb 22, 2024
9c7263b
log
skiffer-git Feb 22, 2024
f381235
log
skiffer-git Feb 22, 2024
063cb44
log
skiffer-git Feb 22, 2024
3ff2811
log
skiffer-git Feb 22, 2024
21aa278
log
skiffer-git Feb 22, 2024
e9b9b72
log
skiffer-git Feb 22, 2024
f776e99
log
skiffer-git Feb 22, 2024
c61a79a
log
skiffer-git Feb 22, 2024
8d4734c
log
skiffer-git Feb 22, 2024
d95a52f
log
skiffer-git Feb 22, 2024
58efba1
log
skiffer-git Feb 22, 2024
bba27c3
log
skiffer-git Feb 22, 2024
80c4b6c
log
skiffer-git Feb 22, 2024
690266c
log
skiffer-git Feb 22, 2024
25d87bf
log
skiffer-git Feb 22, 2024
0ae6336
fix: fix the error output format
luhaoling Feb 22, 2024
c4a9aa5
Merge branch 'fix/script' of github.com:luhaoling/open-im-server into…
luhaoling Feb 22, 2024
0bc93fc
log
skiffer-git Feb 22, 2024
706b0d9
fix: fix the error
luhaoling Feb 22, 2024
6748b8f
Merge branch 'fix/script' of https://github.com/luhaoling/open-im-ser…
luhaoling Feb 22, 2024
585cc93
log
skiffer-git Feb 22, 2024
a8ed65b
log
skiffer-git Feb 22, 2024
f3b27ab
fix: fi the code error
luhaoling Feb 22, 2024
0011542
log
skiffer-git Feb 22, 2024
232f7d1
fix: fix the comflect
luhaoling Feb 22, 2024
559c4ec
log
skiffer-git Feb 22, 2024
c1b2a29
Merge branch 'fix/script' of github.com:luhaoling/open-im-server into…
luhaoling Feb 22, 2024
ce47f30
Merge branch 'fix/script' of github.com:luhaoling/open-im-server into…
luhaoling Feb 22, 2024
7a3e02b
log
skiffer-git Feb 22, 2024
c806549
log
skiffer-git Feb 22, 2024
c0dddb4
log
skiffer-git Feb 22, 2024
14a0b8e
log
skiffer-git Feb 22, 2024
5c00629
log
skiffer-git Feb 22, 2024
9bba016
log
skiffer-git Feb 22, 2024
c176cf5
log
skiffer-git Feb 22, 2024
a84dbac
log
skiffer-git Feb 22, 2024
795b003
log
skiffer-git Feb 22, 2024
2c48d84
log
skiffer-git Feb 22, 2024
202a1ff
log
skiffer-git Feb 22, 2024
169b7fe
log
skiffer-git Feb 22, 2024
b8c930d
log
skiffer-git Feb 22, 2024
dd846a4
log
skiffer-git Feb 22, 2024
001308c
log
skiffer-git Feb 22, 2024
ea4afc6
log
skiffer-git Feb 22, 2024
de2eea7
log
skiffer-git Feb 22, 2024
9a2c74b
log
skiffer-git Feb 22, 2024
df87f94
log
skiffer-git Feb 22, 2024
4c07027
log
skiffer-git Feb 22, 2024
96d493e
log
skiffer-git Feb 22, 2024
7a1d461
log
skiffer-git Feb 22, 2024
3b0a4ba
log
skiffer-git Feb 22, 2024
e09475d
log
skiffer-git Feb 22, 2024
488c3a7
log
skiffer-git Feb 22, 2024
d9e7523
log
skiffer-git Feb 22, 2024
6b92706
log
skiffer-git Feb 22, 2024
83fb847
log
skiffer-git Feb 22, 2024
51ca051
log
skiffer-git Feb 22, 2024
716c5c6
log
skiffer-git Feb 22, 2024
9166588
Merge branch 'openimsdk:main' into fix/script
luhaoling Feb 26, 2024
beeae49
fix: use printf replace the echo
luhaoling Feb 27, 2024
9602498
Merge branch 'fix/script' of github.com:luhaoling/open-im-server into…
luhaoling Feb 27, 2024
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
2 changes: 1 addition & 1 deletion cmd/openim-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func run(port int, proPort int) error {
defer cancel()
select {
case <-sigs:
util.SIGUSR1Exit()
util.SIGTERMExit()
err := server.Shutdown(ctx)
if err != nil {
return errs.Wrap(err, "shutdown err")
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#

set -e
set -o pipefail


############################## OpenIM Github ##############################
# ... rest of the script ...
Expand Down
4 changes: 1 addition & 3 deletions internal/msggateway/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
netDone := make(chan error)
go func() {
err = hubServer.Start()
if err != nil {
netDone <- err
}
netDone <- err
}()
return hubServer.LongConnServer.Run(netDone)
}
6 changes: 2 additions & 4 deletions internal/msgtransfer/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,17 @@ func (m *MsgTransfer) Start(prometheusPort int) error {
signal.Notify(sigs, syscall.SIGTERM)
select {
case <-sigs:
util.SIGUSR1Exit()
util.SIGTERMExit()
// graceful close kafka client.
m.cancel()
m.historyCH.historyConsumerGroup.Close()
m.historyMongoCH.historyConsumerGroup.Close()

return nil
case <-netDone:
m.cancel()
m.historyCH.historyConsumerGroup.Close()
m.historyMongoCH.historyConsumerGroup.Close()
close(netDone)
return netErr
}

return nil
}
4 changes: 2 additions & 2 deletions pkg/common/startrpc/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func Start(
signal.Notify(sigs, syscall.SIGTERM)
select {
case <-sigs:
util.SIGUSR1Exit()
util.SIGTERMExit()
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
if err := gracefulStopWithCtx(ctx, srv.GracefulStop); err != nil {
Expand All @@ -152,7 +152,7 @@ func Start(
if err != nil {
return errs.Wrap(err, "shutdown err")
}
return errors.New("SIGTERM EXIT")
return nil
case <-netDone:
close(netDone)
return netErr
Expand Down
10 changes: 3 additions & 7 deletions pkg/util/genutil/genutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package genutil

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand All @@ -42,15 +41,12 @@ func OutDir(path string) (string, error) {
}

func ExitWithError(err error) {
if errors.Is(err, errors.New("SIGTERM EXIT")) {
os.Exit(-1)
}
progName := filepath.Base(os.Args[0])
fmt.Fprintf(os.Stderr, "\n\n%s exit -1: \n%+v\n\n", progName, err)
fmt.Fprintf(os.Stderr, "%s exit -1: %+v\n", progName, err)
os.Exit(-1)
}

func SIGUSR1Exit() {
func SIGTERMExit() {
progName := filepath.Base(os.Args[0])
fmt.Printf("\n\n%s receive process terminal SIGTERM exit 0\n\n", progName)
fmt.Fprintf(os.Stderr, "Warning %s receive process terminal SIGTERM exit 0\n", progName)
}
2 changes: 1 addition & 1 deletion scripts/advertise.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

set -e
set -o pipefail


. $(dirname ${BASH_SOURCE})/lib/init.sh

Expand Down
6 changes: 3 additions & 3 deletions scripts/build-all-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
# Usage: `scripts/build-all-service.sh`.
# Example: `scripts/build-go.sh WHAT=cmd/kubelet`.

set -o errexit
set -o nounset
set -o pipefail




OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/lib/init.sh"
Expand Down
43 changes: 21 additions & 22 deletions scripts/check-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
# Encapsulated as: `make check`.
# READ: https://github.com/openimsdk/open-im-server/tree/main/scripts/install/environment.sh

set -o errexit
set -o nounset
set -o pipefail




OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/install/common.sh"
Expand Down Expand Up @@ -49,13 +49,6 @@ print_services_and_ports() {
echo "+-------------------------+----------+"
}

handle_error() {
echo "An error occurred. Printing ${STDERR_LOG_FILE} contents:"
cat "${STDERR_LOG_FILE}"
exit 1
}

trap handle_error ERR

# Assuming OPENIM_SERVER_NAME_TARGETS and OPENIM_SERVER_PORT_TARGETS are defined
# Similarly for OPENIM_DEPENDENCY_TARGETS and OPENIM_DEPENDENCY_PORT_TARGETS
Expand All @@ -71,7 +64,6 @@ echo "++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}"
openim::log::info "\n## Check all dependent service ports"
echo "++ The port being checked: ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}"

set +e

# Later, after discarding Docker, the Docker keyword is unreliable, and Kubepods is used
if grep -qE 'docker|kubepods' /proc/1/cgroup || [ -f /.dockerenv ]; then
Expand All @@ -85,22 +77,29 @@ if [[ $? -ne 0 ]]; then
openim::log::error_exit "The service does not start properly, please check the port, query variable definition!"
echo "+++ https://github.com/openimsdk/open-im-server/tree/main/scripts/install/environment.sh +++"
else
echo "++++ Check all dependent service ports successfully !"
openim::log::success "All components depended on by openim are running normally! "
fi

openim::log::info "\n## Check OpenIM service name"
. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check

openim::log::info "\n## Check all OpenIM service ports"
echo "+++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}"
openim::util::check_ports ${OPENIM_SERVER_PORT_LISTARIES[@]}
openim::log::info "\n## Check openim service name:\n${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer"
result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check)
if [[ $? -ne 0 ]]; then
echo "+++ cat openim log file >>> ${LOG_FILE}"
openim::log::error_exit "The service does not start properly, please check the port, query variable definition!"
else
echo "++++ Check all openim service ports successfully !"
openim::log::error "check process failed.\n $result"
fi

set -e

trap - ERR
echo "Check openim service name:"
for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do
echo "$item"
done

result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]})
if [[ $? -ne 0 ]]; then
echo "+++ cat openim log file >>> ${LOG_FILE}"
openim::log::error "check process failed.\n "
echo "$result"
else
openim::log::success "All openim services are running normally! "
fi

6 changes: 3 additions & 3 deletions scripts/cherry-pick.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# checks them out to a branch named:
# automated-cherry-pick-of-<pr>-<target branch>-<timestamp>

set -o errexit
set -o nounset
set -o pipefail




OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/lib/init.sh"
Expand Down
6 changes: 3 additions & 3 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
# shellcheck disable=SC2034 # Variables sourced in other scripts.

# Common utilities, variables and checks for all build scripts.
set -o errexit
set +o nounset
set -o pipefail




# Unset CDPATH, having it set messes up with script import paths
unset CDPATH
Expand Down
6 changes: 3 additions & 3 deletions scripts/docker-start-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail




#fixme This scripts is the total startup scripts
#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
Expand Down
6 changes: 3 additions & 3 deletions scripts/gen-swagger-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

# Script to generate docs from the latest swagger spec.

set -o errexit
set -o nounset
set -o pipefail




# The root of the build/dist directory
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
Expand Down
6 changes: 3 additions & 3 deletions scripts/init-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

# This script automatically initializes various configuration files and can generate example files.

set -o errexit
set -o nounset
set -o pipefail




# Root directory of the OpenIM project
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
Expand Down
4 changes: 2 additions & 2 deletions scripts/init-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#FIXME This script is the startup script for multiple servers.
#FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array.

set -o nounset
set -o pipefail



OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd -P)
source "${OPENIM_ROOT}/scripts/install/common.sh"
Expand Down
6 changes: 3 additions & 3 deletions scripts/install-im-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
# Usage:
# SERVER_IMAGE_VERSION=latest IMAGE_REGISTRY=myregistry ./this_script.sh

set -o errexit
set -o nounset
set -o pipefail




OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/lib/init.sh"
Expand Down
22 changes: 19 additions & 3 deletions scripts/install/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@


# Common utilities, variables and checks for all build scripts.
set -o errexit
set +o nounset
set -o pipefail




# Sourced flag
COMMON_SOURCED=true
Expand Down Expand Up @@ -99,6 +99,22 @@ IFS=" " read -ra OPENIM_SERVER_PORT_TARGETS <<< "$(openim::common::service_port)
readonly OPENIM_SERVER_PORT_TARGETS
readonly OPENIM_SERVER_PORT_LISTARIES=("${OPENIM_SERVER_PORT_TARGETS[@]##*/}")


OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER=()

for target in "${OPENIM_SERVER_BINARIES_NO_TRANSFER[@]}"; do
OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER+=("${OPENIM_OUTPUT_HOSTBIN}/${target}")
done
readonly OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER



OPENIM_ALL_SERVICE_LIBRARIES=()
for target in "${OPENIM_SERVER_BINARIES_NO_CMDUTILS[@]}"; do
OPENIM_ALL_SERVICE_LIBRARIES+=("${OPENIM_OUTPUT_HOSTBIN}/${target}")
done
readonly OPENIM_ALL_SERVICE_LIBRARIES

openim::common::dependency_name() {
local targets=(
redis
Expand Down
6 changes: 3 additions & 3 deletions scripts/install/dependency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

# This script will install the dependencies required for openim

set -o errexit
set +o nounset
set -o pipefail




OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
Expand Down
2 changes: 1 addition & 1 deletion scripts/install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function openim::uninstall::uninstall_openim() {
openim::common::sudo "systemctl stop openim.target"
openim::common::sudo "systemctl disable openim.target"
openim::common::sudo "rm -f /etc/systemd/system/openim.target"
set -o errexit

openim::log::success "openim uninstall success"
}

Expand Down
Loading
Loading