From eeb8041bd5b8acf9a48a89ce42411f4b0e8d4f46 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Sun, 7 Apr 2024 15:20:10 +0800 Subject: [PATCH] Windows can compile and run. --- cmd/openim-api/main.go | 4 ++-- config/log.yml | 2 +- docker-compose.yml | 8 ++++---- scripts-new/bricks.sh | 2 ++ scripts-new/compile.bat | 37 +++++++++++++++++++++++++++++++++++++ scripts-new/start.bat | 17 +++++++++++++++++ 6 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 scripts-new/compile.bat create mode 100644 scripts-new/start.bat diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go index b4c746edc..8f5113a93 100644 --- a/cmd/openim-api/main.go +++ b/cmd/openim-api/main.go @@ -23,8 +23,8 @@ import ( func main() { apiCmd := cmd.NewApiCmd(cmd.ApiServer) - apiCmd.AddPortFlag() - apiCmd.AddPrometheusPortFlag() + //apiCmd.AddPortFlag() + //apiCmd.AddPrometheusPortFlag() if err := apiCmd.Execute(); err != nil { program.ExitWithError(err) } diff --git a/config/log.yml b/config/log.yml index a615e07c8..081393902 100644 --- a/config/log.yml +++ b/config/log.yml @@ -1,4 +1,4 @@ -storageLocation: ./_output/logs/ +storageLocation: ../../../../logs/ rotationTime: 24 remainRotationCount: 2 remainLogLevel: 6 diff --git a/docker-compose.yml b/docker-compose.yml index ea9144743..b263388e0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: - openim redis: - image: redis:7.0.0 + image: "${REDIS_IMAGE}" container_name: redis ports: - "16379:6379" @@ -46,7 +46,7 @@ services: - openim zookeeper: - image: bitnami/zookeeper:3.8 + image: "${ZOOKEEPER_IMAGE}" container_name: zookeeper ports: - "12181:2181" @@ -58,7 +58,7 @@ services: - openim kafka: - image: 'bitnami/kafka:3.5.1' + image: "${KAFKA_IMAGE}" container_name: kafka restart: always user: root @@ -83,7 +83,7 @@ services: minio: - image: minio/minio:RELEASE.2024-01-11T07-46-16Z + image: "${MINIO_IMAGE}" ports: - "10005:9000" - "19090:9090" diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index fb8a98cb4..44901908a 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -24,6 +24,7 @@ start_binaries() { # Loop to start binary the specified number of times for ((i=0; i> "${OPENIM_INIT_LOG_FILE}" 2> >(tee -a "$OPENIM_INIT_ERR_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & done @@ -37,6 +38,7 @@ start_tools() { local bin_full_path=$(get_tool_full_path "$binary") cmd=("$bin_full_path" -c "$OPENIM_OUTPUT_CONFIG") echo "Starting ${cmd[@]}" + cd OPENIM_OUTPUT_HOSTBIN_TOOLS "${cmd[@]}" ret_val=$? if [ $ret_val -eq 0 ]; then diff --git a/scripts-new/compile.bat b/scripts-new/compile.bat new file mode 100644 index 000000000..2d9fd6555 --- /dev/null +++ b/scripts-new/compile.bat @@ -0,0 +1,37 @@ +@echo off +SETLOCAL EnableDelayedExpansion + +SET "ROOT_DIR=%~dp0..\" +SET "OUTPUT_DIR=%ROOT_DIR%_output\bin\platforms\windows\amd64\" + +IF NOT EXIST "%OUTPUT_DIR%" ( + mkdir "%OUTPUT_DIR%" +) + +call :findMainGo "%ROOT_DIR%cmd" + +echo Compilation complete. +goto :eof + +:findMainGo +FOR /R %1 %%d IN (.) DO ( + IF EXIST "%%d\main.go" ( + SET "DIR_PATH=%%d" + SET "DIR_NAME=%%~nxd" + + echo Found main.go in %%d + echo Compiling %%d... + + + pushd "%%d" + SET "GOOS=windows" + SET "GOARCH=amd64" + go build -o "!OUTPUT_DIR!!DIR_NAME!.exe" main.go + if ERRORLEVEL 1 ( + echo Failed to compile %%d + goto :eof + ) + popd + ) +) +goto :eof diff --git a/scripts-new/start.bat b/scripts-new/start.bat new file mode 100644 index 000000000..12c146edb --- /dev/null +++ b/scripts-new/start.bat @@ -0,0 +1,17 @@ +@echo off +SETLOCAL EnableDelayedExpansion + +SET "BIN_DIR=%~dp0..\_output\bin\platforms\windows\amd64" + +SET "CONFIG_DIR=%~dp0..\config" + +cd "%BIN_DIR%" + +FOR %%f IN ("%BIN_DIR%\*.exe") DO ( + echo Starting %%~nf... + echo Command: start "" "%%~nf.exe" -i 0 -c "%CONFIG_DIR%" + start "" "%%~nf.exe" -i 0 -c "%CONFIG_DIR%" + echo %%~nf started. +) + +echo All binaries in the directory have been started.