mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
feat: add scripts format
This commit is contained in:
parent
87893dece2
commit
0b59a2205b
@ -42,7 +42,7 @@ OpenIM is a service platform specifically designed for integrating chat, audio-v
|
|||||||
- 🛡️ API wrapping
|
- 🛡️ API wrapping
|
||||||
- 🌐 Connection management
|
- 🌐 Connection management
|
||||||
|
|
||||||
## 📚 Main Modules:
|
+ 📚 Main Modules:
|
||||||
|
|
||||||
1. 🚀 Initialization and Login
|
1. 🚀 Initialization and Login
|
||||||
2. 👤 User Management
|
2. 👤 User Management
|
||||||
@ -70,11 +70,16 @@ It is built using Golang and supports cross-platform deployment, ensuring a cons
|
|||||||
|
|
||||||
## :rocket: Quick Start
|
## :rocket: Quick Start
|
||||||
|
|
||||||
|
We support many platforms. Here are the addresses for quick experience on the web side:
|
||||||
|
|
||||||
|
👉 **[OpenIM online web demo](https://web-enterprise.rentsoft.cn/)**
|
||||||
|
|
||||||
🤲 To facilitate user experience, we offer various deployment solutions. You can choose your deployment method from the list below:
|
🤲 To facilitate user experience, we offer various deployment solutions. You can choose your deployment method from the list below:
|
||||||
|
|
||||||
+ **[Source Code Deployment Guide](https://docs.openim.io/guides/gettingStarted/imSourceCodeDeployment)**
|
+ **[Source Code Deployment Guide](https://docs.openim.io/guides/gettingStarted/imSourceCodeDeployment)**
|
||||||
+ **[Docker Deployment Guide](https://docs.openim.io/guides/gettingStarted/dockerCompose)**
|
+ **[Docker Deployment Guide](https://docs.openim.io/guides/gettingStarted/dockerCompose)**
|
||||||
+ **[Kubernetes Deployment Guide](https://docs.openim.io/guides/gettingStarted/k8s-deployment)**
|
+ **[Kubernetes Deployment Guide](https://docs.openim.io/guides/gettingStarted/k8s-deployment)**
|
||||||
|
+ **[Mac Developer Deployment Guide](https://docs.openim.io/guides/gettingstarted/mac-deployment-guide)**
|
||||||
|
|
||||||
## :hammer_and_wrench: To Start Developing OpenIM
|
## :hammer_and_wrench: To Start Developing OpenIM
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
|||||||
package flag
|
package flag
|
||||||
|
|
||||||
import (
|
import (
|
||||||
goFlag "flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ func WarnWordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedNam
|
|||||||
// InitFlags normalizes, parses, then logs the command line flags.
|
// InitFlags normalizes, parses, then logs the command line flags.
|
||||||
func InitFlags() {
|
func InitFlags() {
|
||||||
pflag.CommandLine.SetNormalizeFunc(WordSepNormalizeFunc)
|
pflag.CommandLine.SetNormalizeFunc(WordSepNormalizeFunc)
|
||||||
pflag.CommandLine.AddGoFlagSet(goFlag.CommandLine)
|
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrintFlags logs the flags in the flagset.
|
// PrintFlags logs the flags in the flagset.
|
||||||
|
|||||||
173
scripts/bash_beautify.py
Executable file
173
scripts/bash_beautify.py
Executable file
@ -0,0 +1,173 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
#**************************************************************************
|
||||||
|
# Copyright (C) 2011, Paul Lutus *
|
||||||
|
# *
|
||||||
|
# This program is free software; you can redistribute it and/or modify *
|
||||||
|
# it under the terms of the GNU General Public License as published by *
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
# (at your option) any later version. *
|
||||||
|
# *
|
||||||
|
# This program is distributed in the hope that it will be useful, *
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
# GNU General Public License for more details. *
|
||||||
|
# *
|
||||||
|
# You should have received a copy of the GNU General Public License *
|
||||||
|
# along with this program; if not, write to the *
|
||||||
|
# Free Software Foundation, Inc., *
|
||||||
|
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
#**************************************************************************
|
||||||
|
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
PVERSION = '1.0'
|
||||||
|
|
||||||
|
|
||||||
|
class BeautifyBash:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.tab_str = ' '
|
||||||
|
self.tab_size = 2
|
||||||
|
|
||||||
|
def read_file(self, fp):
|
||||||
|
with open(fp) as f:
|
||||||
|
return f.read()
|
||||||
|
|
||||||
|
def write_file(self, fp, data):
|
||||||
|
with open(fp, 'w') as f:
|
||||||
|
f.write(data)
|
||||||
|
|
||||||
|
def beautify_string(self, data, path=''):
|
||||||
|
tab = 0
|
||||||
|
case_stack = []
|
||||||
|
in_here_doc = False
|
||||||
|
defer_ext_quote = False
|
||||||
|
in_ext_quote = False
|
||||||
|
ext_quote_string = ''
|
||||||
|
here_string = ''
|
||||||
|
output = []
|
||||||
|
line = 1
|
||||||
|
for record in re.split('\n', data):
|
||||||
|
record = record.rstrip()
|
||||||
|
stripped_record = record.strip()
|
||||||
|
|
||||||
|
# collapse multiple quotes between ' ... '
|
||||||
|
test_record = re.sub(r'\'.*?\'', '', stripped_record)
|
||||||
|
# collapse multiple quotes between " ... "
|
||||||
|
test_record = re.sub(r'".*?"', '', test_record)
|
||||||
|
# collapse multiple quotes between ` ... `
|
||||||
|
test_record = re.sub(r'`.*?`', '', test_record)
|
||||||
|
# collapse multiple quotes between \` ... ' (weird case)
|
||||||
|
test_record = re.sub(r'\\`.*?\'', '', test_record)
|
||||||
|
# strip out any escaped single characters
|
||||||
|
test_record = re.sub(r'\\.', '', test_record)
|
||||||
|
# remove '#' comments
|
||||||
|
test_record = re.sub(r'(\A|\s)(#.*)', '', test_record, 1)
|
||||||
|
if(not in_here_doc):
|
||||||
|
if(re.search('<<-?', test_record)):
|
||||||
|
here_string = re.sub(
|
||||||
|
'.*<<-?\s*[\'|"]?([_|\w]+)[\'|"]?.*', '\\1', stripped_record, 1)
|
||||||
|
in_here_doc = (len(here_string) > 0)
|
||||||
|
if(in_here_doc): # pass on with no changes
|
||||||
|
output.append(record)
|
||||||
|
# now test for here-doc termination string
|
||||||
|
if(re.search(here_string, test_record) and not re.search('<<', test_record)):
|
||||||
|
in_here_doc = False
|
||||||
|
else: # not in here doc
|
||||||
|
if(in_ext_quote):
|
||||||
|
if(re.search(ext_quote_string, test_record)):
|
||||||
|
# provide line after quotes
|
||||||
|
test_record = re.sub(
|
||||||
|
'.*%s(.*)' % ext_quote_string, '\\1', test_record, 1)
|
||||||
|
in_ext_quote = False
|
||||||
|
else: # not in ext quote
|
||||||
|
if(re.search(r'(\A|\s)(\'|")', test_record)):
|
||||||
|
# apply only after this line has been processed
|
||||||
|
defer_ext_quote = True
|
||||||
|
ext_quote_string = re.sub(
|
||||||
|
'.*([\'"]).*', '\\1', test_record, 1)
|
||||||
|
# provide line before quote
|
||||||
|
test_record = re.sub(
|
||||||
|
'(.*)%s.*' % ext_quote_string, '\\1', test_record, 1)
|
||||||
|
if(in_ext_quote):
|
||||||
|
# pass on unchanged
|
||||||
|
output.append(record)
|
||||||
|
else: # not in ext quote
|
||||||
|
inc = len(re.findall(
|
||||||
|
'(\s|\A|;)(case|then|do)(;|\Z|\s)', test_record))
|
||||||
|
inc += len(re.findall('(\{|\(|\[)', test_record))
|
||||||
|
outc = len(re.findall(
|
||||||
|
'(\s|\A|;)(esac|fi|done|elif)(;|\)|\||\Z|\s)', test_record))
|
||||||
|
outc += len(re.findall('(\}|\)|\])', test_record))
|
||||||
|
if(re.search(r'\besac\b', test_record)):
|
||||||
|
if(len(case_stack) == 0):
|
||||||
|
sys.stderr.write(
|
||||||
|
'File %s: error: "esac" before "case" in line %d.\n' % (
|
||||||
|
path, line)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
outc += case_stack.pop()
|
||||||
|
# sepcial handling for bad syntax within case ... esac
|
||||||
|
if(len(case_stack) > 0):
|
||||||
|
if(re.search('\A[^(]*\)', test_record)):
|
||||||
|
# avoid overcount
|
||||||
|
outc -= 2
|
||||||
|
case_stack[-1] += 1
|
||||||
|
if(re.search(';;', test_record)):
|
||||||
|
outc += 1
|
||||||
|
case_stack[-1] -= 1
|
||||||
|
# an ad-hoc solution for the "else" keyword
|
||||||
|
else_case = (
|
||||||
|
0, -1)[re.search('^(else)', test_record) != None]
|
||||||
|
net = inc - outc
|
||||||
|
tab += min(net, 0)
|
||||||
|
extab = tab + else_case
|
||||||
|
extab = max(0, extab)
|
||||||
|
output.append(
|
||||||
|
(self.tab_str * self.tab_size * extab) + stripped_record)
|
||||||
|
tab += max(net, 0)
|
||||||
|
if(defer_ext_quote):
|
||||||
|
in_ext_quote = True
|
||||||
|
defer_ext_quote = False
|
||||||
|
if(re.search(r'\bcase\b', test_record)):
|
||||||
|
case_stack.append(0)
|
||||||
|
line += 1
|
||||||
|
error = (tab != 0)
|
||||||
|
if(error):
|
||||||
|
sys.stderr.write(
|
||||||
|
'File %s: error: indent/outdent mismatch: %d.\n' % (path, tab))
|
||||||
|
return '\n'.join(output), error
|
||||||
|
|
||||||
|
def beautify_file(self, path):
|
||||||
|
error = False
|
||||||
|
if(path == '-'):
|
||||||
|
data = sys.stdin.read()
|
||||||
|
result, error = self.beautify_string(data, '(stdin)')
|
||||||
|
sys.stdout.write(result)
|
||||||
|
else: # named file
|
||||||
|
data = self.read_file(path)
|
||||||
|
result, error = self.beautify_string(data, path)
|
||||||
|
if(data != result):
|
||||||
|
# make a backup copy
|
||||||
|
self.write_file(path + '~', data)
|
||||||
|
self.write_file(path, result)
|
||||||
|
return error
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
error = False
|
||||||
|
sys.argv.pop(0)
|
||||||
|
if(len(sys.argv) < 1):
|
||||||
|
sys.stderr.write(
|
||||||
|
'usage: shell script filenames or \"-\" for stdin.\n')
|
||||||
|
else:
|
||||||
|
for path in sys.argv:
|
||||||
|
error |= self.beautify_file(path)
|
||||||
|
sys.exit((0, 1)[error])
|
||||||
|
|
||||||
|
# if not called as a module
|
||||||
|
if(__name__ == '__main__'):
|
||||||
|
BeautifyBash().main()
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ readonly ENV_FILE=${ENV_FILE:-"${OPENIM_ROOT}/scripts/install/environment.sh"}
|
|||||||
# Templates for configuration files
|
# Templates for configuration files
|
||||||
declare -A TEMPLATES=(
|
declare -A TEMPLATES=(
|
||||||
["${OPENIM_ROOT}/deployments/templates/env-template.yaml"]="${OPENIM_ROOT}/.env"
|
["${OPENIM_ROOT}/deployments/templates/env-template.yaml"]="${OPENIM_ROOT}/.env"
|
||||||
["${OPENIM_ROOT}/deployments/templates/config.yaml"]="${OPENIM_ROOT}/config/openim.yaml"
|
["${OPENIM_ROOT}/deployments/templates/config.yaml"]="${OPENIM_ROOT}/config/config.yaml"
|
||||||
["${OPENIM_ROOT}/deployments/templates/prometheus.yml"]="${OPENIM_ROOT}/config/prometheus.yml"
|
["${OPENIM_ROOT}/deployments/templates/prometheus.yml"]="${OPENIM_ROOT}/config/prometheus.yml"
|
||||||
["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/alertmanager.yml"
|
["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/alertmanager.yml"
|
||||||
)
|
)
|
||||||
@ -39,7 +39,7 @@ declare -A TEMPLATES=(
|
|||||||
# Templates for example files
|
# Templates for example files
|
||||||
declare -A EXAMPLES=(
|
declare -A EXAMPLES=(
|
||||||
["${OPENIM_ROOT}/deployments/templates/env-template.yaml"]="${OPENIM_ROOT}/config/templates/env.template"
|
["${OPENIM_ROOT}/deployments/templates/env-template.yaml"]="${OPENIM_ROOT}/config/templates/env.template"
|
||||||
["${OPENIM_ROOT}/deployments/templates/config.yaml"]="${OPENIM_ROOT}/config/templates/openim.yaml.template"
|
["${OPENIM_ROOT}/deployments/templates/config.yaml"]="${OPENIM_ROOT}/config/templates/config.yaml.template"
|
||||||
["${OPENIM_ROOT}/deployments/templates/prometheus.yml"]="${OPENIM_ROOT}/config/templates/prometheus.yml.template"
|
["${OPENIM_ROOT}/deployments/templates/prometheus.yml"]="${OPENIM_ROOT}/config/templates/prometheus.yml.template"
|
||||||
["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/templates/alertmanager.yml.template"
|
["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/templates/alertmanager.yml.template"
|
||||||
)
|
)
|
||||||
@ -95,6 +95,10 @@ generate_config_files() {
|
|||||||
# Function to generate example files
|
# Function to generate example files
|
||||||
generate_example_files() {
|
generate_example_files() {
|
||||||
env_cmd="env -i"
|
env_cmd="env -i"
|
||||||
|
|
||||||
|
env_vars["OPENIM_IP"]="127.0.0.1"
|
||||||
|
env_vars["LOG_STORAGE_LOCATION"]="../../"
|
||||||
|
|
||||||
for var in "${!env_vars[@]}"; do
|
for var in "${!env_vars[@]}"; do
|
||||||
env_cmd+=" $var='${env_vars[$var]}'"
|
env_cmd+=" $var='${env_vars[$var]}'"
|
||||||
done
|
done
|
||||||
@ -110,7 +114,6 @@ generate_example_files() {
|
|||||||
local example_file="${COPY_EXAMPLES[$template]}"
|
local example_file="${COPY_EXAMPLES[$template]}"
|
||||||
process_file "$template" "$example_file" false
|
process_file "$template" "$example_file" false
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to process a single file, either by generating or copying
|
# Function to process a single file, either by generating or copying
|
||||||
@ -181,7 +184,6 @@ clean_config_files() {
|
|||||||
|
|
||||||
# Function to clean example files
|
# Function to clean example files
|
||||||
clean_example_files() {
|
clean_example_files() {
|
||||||
# 合并 EXAMPLES 和 COPY_EXAMPLES 数组
|
|
||||||
local all_examples=("${EXAMPLES[@]}" "${COPY_EXAMPLES[@]}")
|
local all_examples=("${EXAMPLES[@]}" "${COPY_EXAMPLES[@]}")
|
||||||
|
|
||||||
for example_file in "${all_examples[@]}"; do
|
for example_file in "${all_examples[@]}"; do
|
||||||
|
|||||||
@ -70,6 +70,10 @@ done < <(find . -name "*.sh" \
|
|||||||
-not \( \
|
-not \( \
|
||||||
-path ./_\* -o \
|
-path ./_\* -o \
|
||||||
-path ./.git\* -o \
|
-path ./.git\* -o \
|
||||||
|
-path ./Godeps\* -o \
|
||||||
|
-path ./_output\* -o \
|
||||||
|
-path ./components\* -o \
|
||||||
|
-path ./logs\* -o \
|
||||||
-path ./vendor\* -o \
|
-path ./vendor\* -o \
|
||||||
\( -path ./third_party\* -a -not -path ./third_party/forked\* \) \
|
\( -path ./third_party\* -a -not -path ./third_party/forked\* \) \
|
||||||
\))
|
\))
|
||||||
|
|||||||
@ -34,7 +34,7 @@ openim_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
|
|||||||
wrkdir="${openim_root}/_output/wrk"
|
wrkdir="${openim_root}/_output/wrk"
|
||||||
jobname="openim-api"
|
jobname="openim-api"
|
||||||
duration="300s"
|
duration="300s"
|
||||||
threads=$((3 * `grep -c processor /proc/cpuinfo`))
|
threads=$((3 * $(grep -c processor /proc/cpuinfo)))
|
||||||
|
|
||||||
source "${openim_root}/scripts/lib/color.sh"
|
source "${openim_root}/scripts/lib/color.sh"
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ if (s ~ "s") {
|
|||||||
|
|
||||||
# Remove existing data file
|
# Remove existing data file
|
||||||
function openim::wrk::prepare() {
|
function openim::wrk::prepare() {
|
||||||
rm -f ${wrkdir}/${datfile}
|
rm -f "${wrkdir}"/"${datfile}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Plot according to gunplot data file
|
# Plot according to gunplot data file
|
||||||
@ -216,7 +216,7 @@ openim::wrk::start_performance_test() {
|
|||||||
do
|
do
|
||||||
wrkcmd="${cmd} -c ${c} $1"
|
wrkcmd="${cmd} -c ${c} $1"
|
||||||
echo "Running wrk command: ${wrkcmd}"
|
echo "Running wrk command: ${wrkcmd}"
|
||||||
result=`eval ${wrkcmd}`
|
result=$(eval "${wrkcmd}")
|
||||||
openim::wrk::convert_plot_data "${result}"
|
openim::wrk::convert_plot_data "${result}"
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -241,9 +241,10 @@ while getopts "hd:n:" opt;do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
shift $(($OPTIND-1))
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
mkdir -p "${wrkdir}"
|
||||||
|
|
||||||
mkdir -p ${wrkdir}
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"diff")
|
"diff")
|
||||||
if [ "$#" -lt 3 ];then
|
if [ "$#" -lt 3 ];then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user