Mik*_*ike 5 windows shutdown apache-nifi
有没有一种简单的编程方法可以在 Windows 上关闭 NiFi?“手动”方式有效,在命令窗口中运行并按 ctr-c 退出,但我正在尝试自动化测试环境。我可以在 Linux 上使用 nifi.sh 脚本,并且在谷歌搜索时看到了对关闭 bat 脚本的引用,但我使用的是 0.6.1,但它不在该版本中。
我使用 netstat 根据 API 端口号查找 PID,然后终止该进程。但似乎总是有两个进程,一个进程会重新启动另一个进程。所以我用 Bootstrap 端口做了同样的事情,用它来查找进程的 PID,然后也杀死了该进程。但这并不总是可靠的。
您可以在 Windows 上停止 nifi。为此,您必须打开run-nifi.bat文件并将文件中的run替换为 stop 。
然后另存为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
Run Code Online (Sandbox Code Playgroud)
现在你只需运行这个文件 nifi-stop.bat 就可以停止 nifi。
NiFi确实支持在Windows上运行,但目前不支持绑定到Windows服务管理。肯定可行,如果您有兴趣通过邮件列表、JIRA 条目和讨论或代码提交来帮助贡献,社区将很乐意合作
归档时间: |
|
查看次数: |
7345 次 |
最近记录: |