feat: add docker compose fix

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
pull/825/head
Xinwei Xiong(cubxxw-openim) 2 years ago
parent 5742932df5
commit 0953f616f0
No known key found for this signature in database
GPG Key ID: 1BAD6F395338EFDE

@ -49,7 +49,7 @@ jobs:
strategy:
matrix:
go_version: ["1.18","1.19","1.20","1.21"]
os: [ubuntu-latest]
os: [ubuntu-latest,macos-latest]
steps:
- name: Set up Go ${{ matrix.go_version }}
@ -89,13 +89,6 @@ jobs:
sudo make build
echo "Build source code for host platform successfully"
- name: OpenIM verify copyright
run: |
sudo make verify-copyright
sudo make add-copyright
echo "OpenIM verify successfully"
continue-on-error: true
- name: Clean all build
run: |
sudo make clean
@ -114,14 +107,6 @@ jobs:
# commit_author: Kubbot # defaults to author of the commit that triggered the run
continue-on-error: true
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore(fmt): robot automated format and lint Change"
commit_options: '--no-verify --signoff'
branch: main
continue-on-error: true
- name: Set Current Directory
id: set_directory
run: |
@ -142,10 +127,6 @@ jobs:
cat ${{ steps.collect_coverage.outputs.coverage_file }}
continue-on-error: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
continue-on-error: true
openim-start:
name: Teat OpenIM make install start on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

@ -51,39 +51,24 @@ jobs:
sudo sleep 60
continue-on-error: true
- name: Stop all services
run: |
sudo chmod +x ./scripts/stop-all.sh
sudo ./scripts/stop-all.sh
sudo cat logs/openIM.log 2>/dev/null
shell: bash
continue-on-error: true
- name: Build all services
run: |
sudo chmod +x ./scripts/build-all-service.sh
sudo ./scripts/build-all-service.sh
sudo cat logs/openIM.log 2>/dev/null
shell: bash
- name: Start all services
run: |
sudo chmod +x ./scripts/start-all.sh
sudo ./scripts/start-all.sh
sudo cat logs/openIM.log 2>/dev/null
continue-on-error: true
shell: bash
- name: Check all services
run: |
sudo chmod +x ./scripts/check-all.sh
sudo ./scripts/check-all.sh
sudo cat logs/openIM.log 2>/dev/null
shell: bash
- name: Print openIM.log
run: |
sudo cat logs/* 2>/dev/null
sudo cat logs/* 2>/dev/null >> "$GITHUB_OUTPUT"
sudo cat ./_output/logs/* 2>/dev/null
sudo cat ./_output/logs/* 2>/dev/null >> "$GITHUB_OUTPUT"
shell: bash
continue-on-error: true

@ -121,12 +121,16 @@ $ make demo
<details> <summary>Deploying with Docker Compose</summary>
> docker compose will not be maintained in future versions, but it is still the easiest and most convenient way to organize docker compose deployments into a separate project https://github.com/openim-sigs/openim-docker to maintain.
**1. Clone the project**
```bash
# choose what you need, We take branch 3.2 as an example
$ BRANCH=release-v3.2
$ git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim && export openim=$(pwd)/openim && cd $openim
$ git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim/openim-server && export openim_dir=$(pwd)/openim && cd ${openim_dir}/openim-server
```
> **Note**
@ -157,7 +161,7 @@ API_URL=http://127.0.0.1:10002/object/ #the app must be able to access this IP
DATA_DIR=./ #designate large disk directory
```
3. **Deploy and start**
**3. Deploy and start**
> **Note**
>
@ -181,10 +185,12 @@ Looking at the command line at this point, there are two items in the output, ch
<details> <summary>Compile from Source</summary>
Ur need `Go 1.18` or higher version, and `make`.
```bash
$ go version; make --version
go version && make --version || echo "Error: One of the commands failed."
```
Version Details: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md
@ -192,23 +198,26 @@ Version Details: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conv
```bash
# choose what you need
$ BRANCH=release-v3.1
$ git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim && export openim=$(pwd)/openim && cd $openim && make build
$ git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim && export openim=$(pwd)/openim && cd $openim && make start
```
Read about the [OpenIM Version Policy](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md)
> `make help` to help you see the instructions supported by OpenIM.
`make help` to help you see the instructions supported by OpenIM.
Use `make check` to check all component starts
All services have been successfully built as shown in the figure
```bash
$ make check
```
![Successful Compilation](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/build.png)
You can use the `make help-all` see OpenIM in action.
</details>
<details> <summary>Component Configuration Instructions</summary>
The `config/config.yaml` file has detailed configuration instructions for the storage components.
The config/config.yaml file has detailed configuration instructions for the storage components.
The config file is available via [environment.sh](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/scripts/install/environment.sh) configuration [openim.yaml](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployments/templates/openim.yaml) template, and then through the `make init` to automatically generate a new configuration.
- Zookeeper
@ -291,26 +300,10 @@ The config/config.yaml file has detailed configuration instructions for the stor
</details>
<details> <summary>Start and Stop Services</summary>
Start services
<details> <summary>Deployed with kubernetes</summary>
```
./scripts/start-all.sh;
```
Check services
```
./scripts/check-all.sh
```
Stop services
```
./scripts/stop-all.sh
```
read: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployments/README.md
</details>
@ -337,6 +330,7 @@ Stop services
</details>
## :link: Relationship Between APP and OpenIM
OpenIM isn't just an open-source instant messaging component, it's an integral part of your application ecosystem. Check out this diagram to understand how AppServer, AppClient, Open-IM-Server, and Open-IM-SDK interact.

@ -0,0 +1,378 @@
# 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.
# -----------------------------------------------------------------
# Infrastructural configurations, please modify based on your setup
# -----------------------------------------------------------------
###################### Zookeeper ######################
# Zookeeper configuration
# It's not recommended to modify the schema
#
# Zookeeper address
# Zookeeper username
# Zookeeper password
zookeeper:
schema: openim
address: [ 127.0.0.1:2181 ]
username:
password:
###################### Mysql ######################
# MySQL configuration
# Currently, only single machine setup is supported
#
# Maximum number of open connections
# Maximum number of idle connections
# Maximum lifetime in seconds a connection can be reused
# Log level: 1=slient, 2=error, 3=warn, 4=info
# Slow query threshold in milliseconds
mysql:
address: [ 127.0.0.1:13306 ]
username: root
password: openIM123
database: openIM_v3
maxOpenConn: 1000
maxIdleConn: 100
maxLifeTime: 60
logLevel: 4
slowThreshold: 500
###################### Mongo ######################
# MongoDB configuration
# If uri is not empty, it will be used directly
#
# MongoDB address for standalone setup, Mongos address for sharded cluster setup
# Default MongoDB database name
# Maximum connection pool size
mongo:
uri:
address: [ 127.0.0.1:37017 ]
database: openIM_v3
username: root
password: openIM123
maxPoolSize: 100
###################### Redis ######################
# Redis configuration
#
# Username is required only for Redis version 6.0+
redis:
address: [ 127.0.0.1:16379 ]
username:
password: openIM123
###################### Kafka ######################
# Kafka configuration
#
# Kafka username
# Kafka password
# It's not recommended to modify this topic name
# Consumer group ID, it's not recommended to modify
kafka:
username:
password:
addr: [ 127.0.0.1:9092 ]
latestMsgToRedis:
topic: "latestMsgToRedis"
offlineMsgToMongo:
topic: "offlineMsgToMongoMysql"
msgToPush:
topic: "msgToPush"
consumerGroupID:
msgToRedis: redis
msgToMongo: mongo
msgToMySql: mysql
msgToPush: push
###################### RPC ######################
# RPC configuration
#
# IP address to register with zookeeper when starting RPC, the IP and corresponding rpcPort should be accessible by api/gateway
# Default listen IP is 0.0.0.0
rpc:
registerIP:
listenIP: 0.0.0.0
###################### API ######################
# API configuration
#
# API service port
# Default listen IP is 0.0.0.0
api:
openImApiPort: [ 10002 ]
listenIP: 0.0.0.0
###################### Gateway ######################
# Object storage configuration
#
# Use minio for object storage
# API URL should be accessible by the app
# It's not recommended to modify the bucket name
# Endpoint should be accessible by the app
# Session token
# Configuration for Tencent COS
# Configuration for Aliyun OSS
# apiURL is the address of the api, the access address of the app, use s3 must be configured
# minio.endpoint can be configured as an intranet address,
# minio.signEndpoint is minio public network address
object:
enable: "minio"
apiURL: "http://127.0.0.1:10002"
minio:
bucket: "openim"
endpoint: "http://127.0.0.1:10005"
accessKeyID: "root"
secretAccessKey: "openIM123"
sessionToken: ""
signEndpoint: "http://127.0.0.1:10005"
cos:
bucketURL: "https://temp-1252357374.cos.ap-chengdu.myqcloud.com"
secretID: ""
secretKey: ""
sessionToken: ""
oss:
endpoint: "https://oss-cn-chengdu.aliyuncs.com"
bucket: "demo-9999999"
bucketURL: "https://demo-9999999.oss-cn-chengdu.aliyuncs.com"
accessKeyID: ""
accessKeySecret: ""
sessionToken: ""
# RPC service ports
# These ports are passed into the program by the script and are not recommended to modify
# For launching multiple programs, just fill in multiple ports separated by commas
# For example, [10110, 10111]
rpcPort:
openImUserPort: [ 10110 ]
openImFriendPort: [ 10120 ]
openImMessagePort: [ 10130 ]
openImMessageGatewayPort: [ 10140 ]
openImGroupPort: [ 10150 ]
openImAuthPort: [ 10160 ]
openImPushPort: [ 10170 ]
openImConversationPort: [ 10180 ]
openImThirdPort: [ 10190 ]
# RPC service names for registration, it's not recommended to modify these
rpcRegisterName:
openImUserName: User
openImFriendName: Friend
openImMsgName: Msg
openImPushName: Push
openImMessageGatewayName: MessageGateway
openImGroupName: Group
openImAuthName: Auth
openImConversationName: Conversation
openImThirdName: Third
# Log configuration
#
# Storage directory
# Log rotation time
# Maximum number of logs to retain
# Log level, 6 means all levels
# Whether to output to stdout
# Whether to output in json format
# Whether to include stack trace in logs
log:
storageLocation: ../../../../../logs/
rotationTime: 24
remainRotationCount: 2
remainLogLevel: 6
isStdout: false
isJson: false
withStack: false
# Long connection server configuration
#
# Websocket port for msg_gateway
# Maximum number of websocket connections
# Maximum length of websocket request package
# Websocket connection handshake timeout
longConnSvr:
openImWsPort: [ 10001 ]
websocketMaxConnNum: 100000
websocketMaxMsgLen: 4096
websocketTimeout: 10
# Push notification service configuration
#
# Use GeTui for push notifications
# GeTui offline push configuration
# FCM offline push configuration
# Account file, place it in the config directory
# JPush configuration, modify these after applying in JPush backend
push:
enable: getui
geTui:
pushUrl: "https://restapi.getui.com/v2/$appId"
masterSecret: ""
appKey: ""
intent: ""
channelID: ""
channelName: ""
fcm:
serviceAccount: "x.json"
jpns:
appKey:
masterSecret:
pushUrl:
pushIntent:
# App manager configuration
#
# Built-in app manager user IDs
# Built-in app manager nicknames
manager:
userID: [ "openIM123456","openIM654321","openIMAdmin" ]
nickname: [ "system1","system2", "system3" ]
# Multi-platform login policy
# For each platform(Android, iOS, Windows, Mac, web), only one can be online at a time
multiLoginPolicy: 1
# Whether to store messages in MySQL, messages in MySQL are only used for management background
chatPersistenceMysql: true
# Message cache timeout in seconds, it's not recommended to modify
msgCacheTimeout: 86400
# Whether to enable read receipts for group chat
groupMessageHasReadReceiptEnable: true
# Whether to enable read receipts for single chat
singleMessageHasReadReceiptEnable: true
# MongoDB offline message retention period in days
retainChatRecords: 365
# Schedule to clear expired messages(older than retainChatRecords days) in MongoDB every Wednesday at 2am
# This deletion is just for cleaning up disk usage according to previous configuration retainChatRecords, no notification will be sent
chatRecordsClearTime: "0 2 * * 3"
# Schedule to auto delete messages every day at 2am
# This deletion is for messages that have been retained for more than msg_destruct_time (seconds) in the conversation field
msgDestructTime: "0 2 * * *"
# Secret key
secret: openIM123
# Token policy
#
# Token expiration period in days
tokenPolicy:
expire: 90
# Message verification policy
#
# Whether to verify friendship when sending messages
messageVerify:
friendVerify: false
# iOS push notification configuration
#
# iOS push notification sound
# Whether to count badge
# Whether it's production environment
iosPush:
pushSound: "xxx"
badgeCount: true
production: false
# Callback configuration
#
# Callback URL
# Whether to enable this callback event
# Timeout in seconds
# Whether to continue execution if callback fails
callback:
url:
beforeSendSingleMsg:
enable: false
timeout: 5
failedContinue: true
afterSendSingleMsg:
enable: false
timeout: 5
beforeSendGroupMsg:
enable: false
timeout: 5
failedContinue: true
afterSendGroupMsg:
enable: false
timeout: 5
msgModify:
enable: false
timeout: 5
failedContinue: true
userOnline:
enable: false
timeout: 5
userOffline:
enable: false
timeout: 5
userKickOff:
enable: false
timeout: 5
offlinePush:
enable: false
timeout: 5
failedContinue: true
onlinePush:
enable: false
timeout: 5
failedContinue: true
superGroupOnlinePush:
enable: false
timeout: 5
failedContinue: true
beforeAddFriend:
enable: false
timeout: 5
failedContinue: true
beforeCreateGroup:
enable: false
timeout: 5
failedContinue: true
beforeMemberJoinGroup:
enable: false
timeout: 5
failedContinue: true
beforeSetGroupMemberInfo:
enable: false
timeout: 5
failedContinue: true
setMessageReactionExtensions:
enable: false
timeout: 5
failedContinue: true
###################### Prometheus ######################
# Prometheus configuration
# The number of Prometheus ports per service needs to correspond to rpcPort
# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh
prometheus:
enable: false
userPrometheusPort: [ 20110 ]
friendPrometheusPort: [ 20120 ]
messagePrometheusPort: [ 20130 ]
messageGatewayPrometheusPort: [ 20140 ]
groupPrometheusPort: [ 20150 ]
authPrometheusPort: [ 20160 ]
pushPrometheusPort: [ 20170 ]
conversationPrometheusPort: [ 20230 ]
rtcPrometheusPort: [ 21300 ]
thirdPrometheusPort: [ 21301 ]
messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ]

@ -133,15 +133,15 @@ services:
image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:latest
# image: openim/openim-chat:latest
container_name: openim-chat
healthcheck:
test: ["CMD-SHELL", "./scripts/check-all.sh"]
interval: 30s
timeout: 10s
retries: 5
# healthcheck:
# test: ["CMD-SHELL", "./scripts/check-all.sh"]
# interval: 30s
# timeout: 10s
# retries: 5
volumes:
- ${DATA_DIR}/_output/openim/openim-chat/logs:/openim/openim-chat/logs
- ${DATA_DIR}/_output/openim/openim-chat/config:/openim/openim-chat/config
- ${DATA_DIR}/_output/openim/openim-chat/scripts:/openim/openim-chat/scripts
- openim-chat_logs:/openim/openim-chat/logs
- openim-chat_config:/openim/openim-chat/config
- openim-chat_scripts:/openim/openim-chat/scripts
restart: always
user: root:root
depends_on:
@ -157,28 +157,34 @@ services:
max-size: "1g"
max-file: "2"
# prometheus:
# image: prom/prometheus
# volumes:
# - ./.docker-compose_cfg/prometheus-compose.yml:/etc/prometheus/prometheus.yml
# container_name: prometheus
# # ports:
# # - 9091:9091
# depends_on:
# - openim-server
# command: --web.listen-address=:9091 --config.file="/etc/prometheus/prometheus.yml"
# network_mode: "host"
prometheus:
image: prom/prometheus
volumes:
- ./.docker-compose_cfg/prometheus-compose.yml:/etc/prometheus/prometheus.yml
container_name: prometheus
# ports:
# - 9091:9091
depends_on:
- openim-server
command: --web.listen-address=:9091 --config.file="/etc/prometheus/prometheus.yml"
network_mode: "host"
grafana:
image: grafana/grafana
volumes:
- ./.docker-compose_cfg/datasource-compose.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
- ./.docker-compose_cfg/grafana.ini:/etc/grafana/grafana.ini
- ./.docker-compose_cfg/node-exporter-full_rev1.json:/var/lib/grafana/dashboards/node-exporter-full_rev1.json
container_name: grafana
depends_on:
- prometheus
network_mode: "host"
# grafana:
# image: grafana/grafana
# volumes:
# - ./.docker-compose_cfg/datasource-compose.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
# - ./.docker-compose_cfg/grafana.ini:/etc/grafana/grafana.ini
# - ./.docker-compose_cfg/node-exporter-full_rev1.json:/var/lib/grafana/dashboards/node-exporter-full_rev1.json
# container_name: grafana
# depends_on:
# - prometheus
# network_mode: "host"
volumes:
data_volume:
openim-chat_logs:
openim-chat_config:
openim-chat_scripts:
# node-exporter:
# image: quay.io/prometheus/node-exporter

@ -65,12 +65,12 @@ It is critical that our full community is actively engaged on enhancements in th
### Steps
- Run the [cherry pick script](https://github.com/OpenIMSDK/Open-IM-Server/tree/main/scripts/cherry_pick_pull.sh)
- Run the [cherry pick script](https://github.com/OpenIMSDK/Open-IM-Server/tree/main/scripts/cherry-pick.sh)
This example applies a main branch PR #98765 to the remote branch `upstream/release-v3.1`:
```
scripts/cherry_pick_pull.sh upstream/release-v3.1 98765
scripts/cherry-pick.sh upstream/release-v3.1 98765
```
- Be aware the cherry pick script assumes you have a git remote called `upstream` that points at the openim-server github org.

@ -1,51 +0,0 @@
#!/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/lib/init.sh
source $SCRIPTS_ROOT/path_info.sh
cd $SCRIPTS_ROOT
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}"
service_port_name=(
openImChatApiPort
openImAdminApiPort
#api port name
openImAdminPort
openImChatPort
)
for i in ${service_port_name[*]}; do
list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}')
openim::util::list-to-string $list
for j in ${ports_array}; do
port=$(ss -tunlp| grep openim | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
if [[ ${port} -ne ${j} ]]; then
echo -e ${BACKGROUND_GREEN}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${BACKGROUND_GREEN}${j}${COLOR_SUFFIX}
echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log"${COLOR_SUFFIX}
exit -1
else
echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX}
fi
done
done

@ -1,29 +0,0 @@
#!/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.
#input:[10023,2323,3434]
#output:10023 2323 3434
openim::util::list-to-string(){
ports_list=$*
sub_s1=`echo $ports_list | sed 's/ //g'`
sub_s2=${sub_s1//,/ }
sub_s3=${sub_s2#*[}
sub_s4=${sub_s3%]*}
ports_array=$sub_s4
}
openim::util::remove_space(){
value=$*
result=`echo $value | sed 's/ //g'`
}

@ -1,25 +0,0 @@
#Don't put the space between "="
demo_server_name="chat-api"
demo_server_binary_root="$BIN_DIR/"
#Global configuration file default dir
config_path="../.docker-compose_cfg/config.yaml"
#servicefile dir path
service_source_root=(
#api service file
../cmd/api/chat/
../cmd/api/admin/
#rpc service file
../cmd/rpc/admin/
../cmd/rpc/chat/
)
#service filename
service_names=(
chat-api
admin-api
admin-rpc
chat-rpc
)

@ -13,11 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Use this script to test if a given TCP host/port are available
WAITFORIT_cmdname=${0##*/}
. $(dirname ${BASH_SOURCE})/lib/init.sh
echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then info "$@" 1>&2; fi }
echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
usage()
{
@ -36,7 +34,7 @@ USAGE
exit 1
}
function wait_for()
wait_for()
{
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
@ -50,7 +48,7 @@ function wait_for()
nc -z $WAITFORIT_HOST $WAITFORIT_PORT
WAITFORIT_result=$?
else
(echo > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
(echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
WAITFORIT_result=$?
fi
if [[ $WAITFORIT_result -eq 0 ]]; then
@ -63,7 +61,7 @@ function wait_for()
return $WAITFORIT_result
}
function wait_for_wrapper()
wait_for_wrapper()
{
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
if [[ $WAITFORIT_QUIET -eq 1 ]]; then
@ -139,7 +137,7 @@ do
usage
;;
*)
warn "Unknown argument: $1"
echoerr "Unknown argument: $1"
usage
;;
esac
@ -155,16 +153,20 @@ WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
# check to see if timeout is from busybox?
# Check to see if timeout is from busybox?
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
WAITFORIT_BUSYTIMEFLAG=""
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
WAITFORIT_ISBUSY=1
WAITFORIT_ISBUSY=1
# Check if busybox timeout uses -t flag
# (recent Alpine versions don't support -t anymore)
if timeout &>/dev/stdout | grep -q -e '-t '; then
WAITFORIT_BUSYTIMEFLAG="-t"
fi
else
WAITFORIT_ISBUSY=0
WAITFORIT_BUSYTIMEFLAG=""
WAITFORIT_ISBUSY=0
fi
if [[ $WAITFORIT_CHILD -gt 0 ]]; then

Loading…
Cancel
Save