Is there an easy programmatic way to shutdown NiFi on windows? The "manual" way works, run in a command window and press ctr-c to quit, but I'm trying to automate a testing environment. I can use the nifi.sh script on linux and I've seen reference to a shutdown bat script when googling but I'm using 0.6.1 and it isn't in that version.
I've used netstat to find the PID based on the API Port number and then killed that process. But it appears there are always two processes and one will restart the other. So I did the same thing, with the Bootstrap port, used it to find the PID of the process and then killed that process as well. But this hasn't always been reliable.
If you start NiFi in the background, to check the status and see if NiFi is currently running, execute the command /bin/nifi.sh status. To shut down NiFi, execute the command bin/nifi.sh stop . From a terminal window, navigate to the NiFi installation directory.
To run NiFi in the background, instead run bin/nifi.sh start . This will initiate the application to begin running. To check the status and see if NiFi is currently running, execute the command bin/nifi.sh status . NiFi can be shutdown by executing the command bin/nifi.sh stop .
You can stop nifi on windows. To do that you have to open run-nifi.bat file and replace run to stop in the file.
Then save as the file as nifi-stop.bat
So the content of nifi-stop.bat will looks like this.
@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
Now you can stop nifi just running this file nifi-stop.bat.
NiFi does support running on Windows but does not currently support tying into the Windows Service Management. Doable for sure and if you're interested helping contribute either via mailing list, JIRA entry and discussion or code commits the community would be happy to collaborate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With