gpt4 book ai didi

windows - 在 Windows 上关闭 NiFi

转载 作者:可可西里 更新时间:2023-11-01 10:16:56 26 4
gpt4 key购买 nike

是否有一种简单的编程方式可以在 Windows 上关闭 NiFi? “手动”方式有效,在命令窗口中运行并按 ctr-c 退出,但我正在尝试自动化测试环境。我可以在 linux 上使用 nifi.sh 脚本,我在谷歌搜索时看到了对关闭 bat 脚本的引用,但我使用的是 0.6.1,但它不在那个版本中。

我使用 netstat 根据 API 端口号查找 PID,然后终止该进程。但似乎总是有两个进程,一个将重新启动另一个。所以我做了同样的事情,使用 Bootstrap 端口,用它来查找进程的 PID,然后也终止该进程。但这并不总是可靠的。

最佳答案

您可以在 Windows 上停止 nifi。为此,您必须打开 run-nifi.bat 文件并替换 run 以在文件中停止。

然后将文件另存为nifi-stop.bat

所以 nifi-stop.bat 的内容将如下所示。

@echo off
rem
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem

rem Set environment variables

call %~sdp0\nifi-env.bat

rem Use JAVA_HOME if it's set; otherwise, just use java

if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
set JAVA_EXE=%JAVA_HOME%\bin\java.exe
goto startNifi

:noJavaHome
echo The JAVA_HOME environment variable is not defined correctly.
echo Instead the PATH will be used to find the java executable.
echo.
set JAVA_EXE=java
goto startNifi

:startNifi
pushd "%NIFI_ROOT%"
set LIB_DIR=lib\bootstrap
set CONF_DIR=conf

set BOOTSTRAP_CONF_FILE=%CONF_DIR%\bootstrap.conf
set JAVA_ARGS=-Dorg.apache.nifi.bootstrap.config.log.dir=%NIFI_LOG_DIR% -Dorg.apache.nifi.bootstrap.config.pid.dir=%NIFI_PID_DIR% -Dorg.apache.nifi.bootstrap.config.file=%BOOTSTRAP_CONF_FILE%

SET JAVA_PARAMS=-cp %CONF_DIR%;%LIB_DIR%\* -Xms12m -Xmx24m %JAVA_ARGS% org.apache.nifi.bootstrap.RunNiFi
set BOOTSTRAP_ACTION=stop

cmd.exe /C "%JAVA_EXE%" %JAVA_PARAMS% %BOOTSTRAP_ACTION%

popd

现在你可以停止nifi只运行这个文件nifi-stop.bat。

关于windows - 在 Windows 上关闭 NiFi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38088527/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com