windows启动脚本支持任意路径,增加PowerShell启动脚本.
This commit is contained in:
@@ -34,7 +34,7 @@ github下载慢也可以试试从gitee下载,点击下载[gitee来源kafka-con
|
|||||||
## 快速使用
|
## 快速使用
|
||||||
### Windows
|
### Windows
|
||||||
1. 解压缩zip安装包
|
1. 解压缩zip安装包
|
||||||
2. 进入bin目录(必须在bin目录下),双击执行`start.bat`启动
|
2. 进入bin目录, 双击执行`start.bat`启动; 如果使用PowerShell, 也可以选择运行`start.ps1`启动
|
||||||
3. 停止:直接关闭启动的命令行窗口即可
|
3. 停止:直接关闭启动的命令行窗口即可
|
||||||
|
|
||||||
### Linux或Mac OS
|
### Linux或Mac OS
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<includes>
|
<includes>
|
||||||
<include>*.sh</include>
|
<include>*.sh</include>
|
||||||
<include>*.bat</include>
|
<include>*.bat</include>
|
||||||
|
<include>*.ps1</include>
|
||||||
</includes>
|
</includes>
|
||||||
<outputDirectory>bin</outputDirectory>
|
<outputDirectory>bin</outputDirectory>
|
||||||
<fileMode>0755</fileMode>
|
<fileMode>0755</fileMode>
|
||||||
|
|||||||
@@ -1,8 +1,38 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
rem MAIN_CLASS=org.springframework.boot.loader.JarLauncher
|
rem MAIN_CLASS=org.springframework.boot.loader.JarLauncher
|
||||||
rem JAVA_HOME=jre1.8.0_66
|
rem JAVA_HOME=jre1.8.0_66
|
||||||
set JAVA_CMD=%JAVA_HOME%\bin\java
|
|
||||||
set JAVA_OPTS=-Xmx512m -Xms512m -Xmn256m -Xss256k -Dfile.encoding=utf-8
|
setlocal enabledelayedexpansion
|
||||||
set CONFIG_FILE=../config/application.yml
|
|
||||||
set TARGET=../lib/kafka-console-ui.jar
|
set "BIN_DIR=%~dp0"
|
||||||
set DATA_DIR=..
|
if not "%BIN_DIR:~-1%"=="\" set "BIN_DIR=%BIN_DIR%\"
|
||||||
"%JAVA_CMD%" -jar %TARGET% --spring.config.location=%CONFIG_FILE% --data.dir=%DATA_DIR%
|
|
||||||
|
set "BASE_DIR=%BIN_DIR%.."
|
||||||
|
for %%I in ("%BASE_DIR%") do set "BASE_DIR=%%~fI"
|
||||||
|
|
||||||
|
if defined JAVA_HOME (
|
||||||
|
set "JAVA_CMD=%JAVA_HOME%\bin\java"
|
||||||
|
) else (
|
||||||
|
echo ERROR: JAVA_HOME is not defined
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
set "JAVA_OPTS=-Xmx512m -Xms512m -Xmn256m -Xss256k -Dfile.encoding=utf-8"
|
||||||
|
|
||||||
|
set "CONFIG_FILE=%BASE_DIR%\config\application.yml"
|
||||||
|
set "TARGET=%BASE_DIR%\lib\kafka-console-ui.jar"
|
||||||
|
set "DATA_DIR=%BASE_DIR%"
|
||||||
|
set "LOG_HOME=%BASE_DIR%"
|
||||||
|
|
||||||
|
if not exist "%TARGET%" (
|
||||||
|
echo ERROR: Jar file not found at [%TARGET%]
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
if not exist "%CONFIG_FILE%" (
|
||||||
|
echo WARNING: Config file not found at [%CONFIG_FILE%]
|
||||||
|
)
|
||||||
|
|
||||||
|
"%JAVA_CMD%" %JAVA_OPTS% -jar "%TARGET%" --spring.config.location="%CONFIG_FILE%" --data.dir="%DATA_DIR%" --logging.home="%LOG_HOME%"
|
||||||
|
|
||||||
|
endlocal
|
||||||
41
bin/start.ps1
Normal file
41
bin/start.ps1
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# PowerShell
|
||||||
|
# Set the script execution policy. If necessary, execute this command in PowerShell and then run the script.
|
||||||
|
# Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||||
|
|
||||||
|
param()
|
||||||
|
|
||||||
|
$BIN_DIR = $PSScriptRoot
|
||||||
|
if (-not $BIN_DIR.EndsWith('\')) {
|
||||||
|
$BIN_DIR += '\'
|
||||||
|
}
|
||||||
|
|
||||||
|
$BASE_DIR = (Get-Item (Join-Path $BIN_DIR "..")).FullName
|
||||||
|
|
||||||
|
if (-not $env:JAVA_HOME) {
|
||||||
|
Write-Error "ERROR: JAVA_HOME is not defined"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$JAVA_OPTS = "-Xmx512m -Xms512m -Xmn256m -Xss256k -Dfile.encoding=utf-8"
|
||||||
|
|
||||||
|
$CONFIG_FILE = Join-Path $BASE_DIR "config\application.yml"
|
||||||
|
$TARGET = Join-Path $BASE_DIR "lib\kafka-console-ui.jar"
|
||||||
|
$DATA_DIR = $BASE_DIR
|
||||||
|
$LOG_HOME = $BASE_DIR
|
||||||
|
|
||||||
|
if (-not (Test-Path $TARGET -PathType Leaf)) {
|
||||||
|
Write-Error "ERROR: Jar file not found at [$TARGET]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Path $CONFIG_FILE -PathType Leaf)) {
|
||||||
|
Write-Warning "WARNING: Config file not found at [$CONFIG_FILE]"
|
||||||
|
}
|
||||||
|
|
||||||
|
$javaCmd = Join-Path $env:JAVA_HOME "bin\java.exe"
|
||||||
|
|
||||||
|
& $javaCmd $JAVA_OPTS.Split() `
|
||||||
|
-jar $TARGET `
|
||||||
|
"--spring.config.location=$CONFIG_FILE" `
|
||||||
|
"--data.dir=$DATA_DIR" `
|
||||||
|
"--logging.home=$LOG_HOME"
|
||||||
Reference in New Issue
Block a user