mirror of https://github.com/apache/nifi.git
NIFI-145: Added batch scripts and a simple bootstrap.conf file and fixed ShutdownHook to be Java 7 compliant
This commit is contained in:
parent
646570490c
commit
eed4a9bb81
|
@ -0,0 +1,15 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
rem Use JAVA_HOME if it's set; otherwise, just use java
|
||||||
|
IF "%JAVA_HOME%"=="" (SET JAVA_EXE=java) ELSE (SET JAVA_EXE=%JAVA_HOME%\bin\java.exe)
|
||||||
|
|
||||||
|
SET LIB_DIR=%~dp0..\lib
|
||||||
|
SET CONF_DIR=%~dp0..\conf
|
||||||
|
|
||||||
|
SET BOOTSTRAP_CONF_FILE=%CONF_DIR%\bootstrap.conf
|
||||||
|
SET JAVA_ARGS=-Dorg.apache.nifi.boostrap.config.file=%BOOTSTRAP_CONF_FILE%
|
||||||
|
|
||||||
|
SET JAVA_PARAMS=-cp %LIB_DIR%\nifi-bootstrap*.jar -Xms12m -Xmx24m %JAVA_ARGS% org.apache.nifi.bootstrap.RunNiFi
|
||||||
|
SET BOOTSTRAP_ACTION=status
|
||||||
|
|
||||||
|
cmd.exe /C "%JAVA_EXE%" %JAVA_PARAMS% %BOOTSTRAP_ACTION%
|
|
@ -0,0 +1,15 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
rem Use JAVA_HOME if it's set; otherwise, just use java
|
||||||
|
IF "%JAVA_HOME%"=="" (SET JAVA_EXE=java) ELSE (SET JAVA_EXE=%JAVA_HOME%\bin\java.exe)
|
||||||
|
|
||||||
|
SET LIB_DIR=%~dp0..\lib
|
||||||
|
SET CONF_DIR=%~dp0..\conf
|
||||||
|
|
||||||
|
SET BOOTSTRAP_CONF_FILE=%CONF_DIR%\bootstrap.conf
|
||||||
|
SET JAVA_ARGS=-Dorg.apache.nifi.boostrap.config.file=%BOOTSTRAP_CONF_FILE%
|
||||||
|
|
||||||
|
SET JAVA_PARAMS=-cp %LIB_DIR%\nifi-bootstrap*.jar -Xms12m -Xmx24m %JAVA_ARGS% org.apache.nifi.bootstrap.RunNiFi
|
||||||
|
SET BOOTSTRAP_ACTION=start
|
||||||
|
|
||||||
|
cmd.exe /C "%JAVA_EXE%" %JAVA_PARAMS% %BOOTSTRAP_ACTION%
|
|
@ -0,0 +1,15 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
rem Use JAVA_HOME if it's set; otherwise, just use java
|
||||||
|
IF "%JAVA_HOME%"=="" (SET JAVA_EXE=java) ELSE (SET JAVA_EXE=%JAVA_HOME%\bin\java.exe)
|
||||||
|
|
||||||
|
SET LIB_DIR=%~dp0..\lib
|
||||||
|
SET CONF_DIR=%~dp0..\conf
|
||||||
|
|
||||||
|
SET BOOTSTRAP_CONF_FILE=%CONF_DIR%\bootstrap.conf
|
||||||
|
SET JAVA_ARGS=-Dorg.apache.nifi.boostrap.config.file=%BOOTSTRAP_CONF_FILE%
|
||||||
|
|
||||||
|
SET JAVA_PARAMS=-cp %LIB_DIR%\nifi-bootstrap*.jar -Xms12m -Xmx24m %JAVA_ARGS% org.apache.nifi.bootstrap.RunNiFi
|
||||||
|
SET BOOTSTRAP_ACTION=stop
|
||||||
|
|
||||||
|
cmd.exe /C "%JAVA_EXE%" %JAVA_PARAMS% %BOOTSTRAP_ACTION%
|
|
@ -0,0 +1,9 @@
|
||||||
|
lib.dir=./lib
|
||||||
|
conf.dir=./conf
|
||||||
|
java.arg.1=-Dorg.apache.jasper.compiler.disablejsr199=true
|
||||||
|
|
||||||
|
java.arg.2=-Xms256m
|
||||||
|
java.arg.3=-Xmx512m
|
||||||
|
|
||||||
|
# Enable Remote Debugging
|
||||||
|
#java.arg.2=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
|
|
@ -53,19 +53,36 @@ public class ShutdownHook extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
System.out.println("Waiting for Apache NiFi to finish shutting down...");
|
||||||
nifiProcess.waitFor(WAIT_SECONDS, TimeUnit.SECONDS);
|
final long startWait = System.nanoTime();
|
||||||
} catch (final InterruptedException ie) {
|
while ( isAlive(nifiProcess) ) {
|
||||||
|
final long waitNanos = System.nanoTime() - startWait;
|
||||||
|
final long waitSeconds = TimeUnit.NANOSECONDS.toSeconds(waitNanos);
|
||||||
|
if ( waitSeconds >= WAIT_SECONDS ) {
|
||||||
|
if ( isAlive(nifiProcess) ) {
|
||||||
|
System.out.println("NiFi has not finished shutting down after " + WAIT_SECONDS + " seconds. Killing process.");
|
||||||
|
nifiProcess.destroy();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
} catch (final InterruptedException ie) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( nifiProcess.isAlive() ) {
|
|
||||||
System.out.println("NiFi has not finished shutting down after " + WAIT_SECONDS + " seconds. Killing process.");
|
|
||||||
}
|
|
||||||
nifiProcess.destroy();
|
|
||||||
|
|
||||||
final File statusFile = runner.getStatusFile();
|
final File statusFile = runner.getStatusFile();
|
||||||
if ( !statusFile.delete() ) {
|
if ( !statusFile.delete() ) {
|
||||||
System.err.println("Failed to delete status file " + statusFile.getAbsolutePath());
|
System.err.println("Failed to delete status file " + statusFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isAlive(final Process process) {
|
||||||
|
try {
|
||||||
|
process.exitValue();
|
||||||
|
return false;
|
||||||
|
} catch (final IllegalThreadStateException itse) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue