You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/09/06 14:36:03 UTC
[GitHub] [nifi] exceptionfactory opened a new pull request, #6370: NIFI-9500 Add nifi.cmd for Windows
exceptionfactory opened a new pull request, #6370:
URL: https://github.com/apache/nifi/pull/6370
# Summary
[NIFI-9500](https://issues.apache.org/jira/browse/NIFI-9500) Adds a `nifi.cmd` script for running application actions on Windows.
The implementation contains a basic set of capabilities similar to `nifi.sh`, including support for the `set-single-user-credentials`, `set-sensitive-properties-key`, and `set-sensitive-properties-algorithm` commands.
The script leverages a new `nifi-env.cmd` to avoid depending on the current `nifi-env.bat` script. The `cmd` approach and current directory resolution avoids directory name truncation artifacts present in the `bat` versions.
This implementation should provide a way forward for support on Windows, with the opportunity to deprecate the `bat` files in a future major release version.
# Tracking
Please complete the following tracking steps prior to pull request creation.
### Issue Tracking
- [X] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
### Pull Request Tracking
- [X] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
- [X] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
### Pull Request Formatting
- [X] Pull Request based on current revision of the `main` branch
- [X] Pull Request refers to a feature branch with one commit containing changes
# Verification
Please indicate the verification steps performed prior to pull request creation.
### Build
- [X] Build completed using `mvn clean install -P contrib-check`
- [X] JDK 8
- [ ] JDK 11
- [ ] JDK 17
### Licensing
- [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
- [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
### Documentation
- [ ] Documentation formatting appears as expected in rendered files
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] exceptionfactory commented on a diff in pull request #6370: NIFI-9500 Add nifi.cmd for Windows
Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on code in PR #6370:
URL: https://github.com/apache/nifi/pull/6370#discussion_r968351065
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.cmd:
##########
@@ -0,0 +1,56 @@
+@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
+
+call %~dp0\nifi-env.cmd
+
+if exist "%JAVA_HOME%\bin\java.exe" (
+ set JAVA_EXE=%JAVA_HOME%\bin\java.exe
+) else (
+ echo JAVA_HOME not defined: using PATH for java command
+ set JAVA_EXE=java
+)
+
+set BOOTSTRAP_LIB_DIR=%NIFI_HOME%\lib\bootstrap
+set CONF_DIR=%NIFI_HOME%\conf
+
+set LOG_DIR_PROPERTY=-Dorg.apache.nifi.bootstrap.config.log.dir=%NIFI_LOG_DIR%
+set PID_DIR_PROPERTY=-Dorg.apache.nifi.bootstrap.config.pid.dir=%NIFI_PID_DIR%
+set CONFIG_FILE_PROPERTY=-Dorg.apache.nifi.bootstrap.config.file=%CONF_DIR%\bootstrap.conf
+set PROPERTIES_FILE_PROPERTY=-Dnifi.properties.file.path=%CONF_DIR%\nifi.properties
+set BOOTSTRAP_HEAP_SIZE=48m
+
+set JAVA_ARGS=%LOG_DIR_PROPERTY% %PID_DIR_PROPERTY% %CONFIG_FILE_PROPERTY% %PROPERTIES_FILE_PROPERTY%
+set JAVA_PARAMS=-cp %BOOTSTRAP_LIB_DIR%\*;%CONF_DIR% %JAVA_ARGS%
+set JAVA_MEMORY=-Xms%BOOTSTRAP_HEAP_SIZE% -Xmx%BOOTSTRAP_HEAP_SIZE%
+
+echo JAVA_HOME: %JAVA_HOME%
+echo NIFI_HOME: %NIFI_HOME%
+echo.
+
+set RUN_COMMAND="%~1"
+if %RUN_COMMAND% == "set-single-user-credentials" (
+ rem Set credentials with quoted arguments passed to Java command
+ set "CREDENTIALS=^"%~2^" ^"%~3^""
+ call "%JAVA_EXE%" %JAVA_PARAMS% org.apache.nifi.authentication.single.user.command.SetSingleUserCredentials %CREDENTIALS%
+) else if %RUN_COMMAND% == "set-sensitive-properties-key" (
+ call "%JAVA_EXE%" %JAVA_PARAMS% org.apache.nifi.flow.encryptor.command.SetSensitivePropertiesKey %~2
+) else if %RUN_COMMAND% == "set-sensitive-properties-algorithm" (
+ call "%JAVA_EXE%" %JAVA_PARAMS% org.apache.nifi.flow.encryptor.command.SetSensitivePropertiesAlgorithm %~2
+) else (
+ call "%JAVA_EXE%" %JAVA_MEMORY% %JAVA_PARAMS% org.apache.nifi.bootstrap.RunNiFi %RUN_COMMAND%
Review Comment:
Unlike the `nifi.sh` script, the `nifi.cmd` script on Windows is not able to run a command in the background, so the `start` and `run` actions keep the process in the foreground. This follows the existing behavior of the `run-nifi.bat` script. There may be more advanced approaches that could be implemented with PowerShell, but it seems like it would be better to consider them as future capabilities.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] greyp9 closed pull request #6370: NIFI-9500 Add nifi.cmd for Windows
Posted by GitBox <gi...@apache.org>.
greyp9 closed pull request #6370: NIFI-9500 Add nifi.cmd for Windows
URL: https://github.com/apache/nifi/pull/6370
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] exceptionfactory commented on pull request #6370: NIFI-9500 Add nifi.cmd for Windows
Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on PR #6370:
URL: https://github.com/apache/nifi/pull/6370#issuecomment-1243712805
Thanks for the feedback @greyp9! I pushed an update to change to the NiFi Home directory while running the command action, following the pattern of the `nifi.sh` script.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] MikeThomsen commented on pull request #6370: NIFI-9500 Add nifi.cmd for Windows
Posted by GitBox <gi...@apache.org>.
MikeThomsen commented on PR #6370:
URL: https://github.com/apache/nifi/pull/6370#issuecomment-1242709494
Would it make more sense to use PowerShell given that that seems to be the modern standard for Windows Server?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] thenatog commented on pull request #6370: NIFI-9500 Add nifi.cmd for Windows
Posted by GitBox <gi...@apache.org>.
thenatog commented on PR #6370:
URL: https://github.com/apache/nifi/pull/6370#issuecomment-1241118553
Will review..
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] exceptionfactory commented on pull request #6370: NIFI-9500 Add nifi.cmd for Windows
Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on PR #6370:
URL: https://github.com/apache/nifi/pull/6370#issuecomment-1242725945
> Would it make more sense to use PowerShell given that that seems to be the modern standard for Windows Server?
That's a good question. NiFi should also be capable of running on Windows 10 and 11, in addition to Windows Server, but both of those versions also support PowerShell. Introducing this `cmd` version should provide the greatest degree of compatibility, but following up with a PowerShell version and replacing this and other `bat` scripts seems worth considering.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] greyp9 commented on a diff in pull request #6370: NIFI-9500 Add nifi.cmd for Windows
Posted by GitBox <gi...@apache.org>.
greyp9 commented on code in PR #6370:
URL: https://github.com/apache/nifi/pull/6370#discussion_r967912591
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.cmd:
##########
@@ -0,0 +1,56 @@
+@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
+
+call %~dp0\nifi-env.cmd
+
+if exist "%JAVA_HOME%\bin\java.exe" (
+ set JAVA_EXE=%JAVA_HOME%\bin\java.exe
+) else (
+ echo JAVA_HOME not defined: using PATH for java command
+ set JAVA_EXE=java
+)
+
+set BOOTSTRAP_LIB_DIR=%NIFI_HOME%\lib\bootstrap
+set CONF_DIR=%NIFI_HOME%\conf
+
+set LOG_DIR_PROPERTY=-Dorg.apache.nifi.bootstrap.config.log.dir=%NIFI_LOG_DIR%
+set PID_DIR_PROPERTY=-Dorg.apache.nifi.bootstrap.config.pid.dir=%NIFI_PID_DIR%
+set CONFIG_FILE_PROPERTY=-Dorg.apache.nifi.bootstrap.config.file=%CONF_DIR%\bootstrap.conf
+set PROPERTIES_FILE_PROPERTY=-Dnifi.properties.file.path=%CONF_DIR%\nifi.properties
+set BOOTSTRAP_HEAP_SIZE=48m
+
+set JAVA_ARGS=%LOG_DIR_PROPERTY% %PID_DIR_PROPERTY% %CONFIG_FILE_PROPERTY% %PROPERTIES_FILE_PROPERTY%
+set JAVA_PARAMS=-cp %BOOTSTRAP_LIB_DIR%\*;%CONF_DIR% %JAVA_ARGS%
+set JAVA_MEMORY=-Xms%BOOTSTRAP_HEAP_SIZE% -Xmx%BOOTSTRAP_HEAP_SIZE%
+
+echo JAVA_HOME: %JAVA_HOME%
+echo NIFI_HOME: %NIFI_HOME%
+echo.
+
+set RUN_COMMAND="%~1"
+if %RUN_COMMAND% == "set-single-user-credentials" (
+ rem Set credentials with quoted arguments passed to Java command
+ set "CREDENTIALS=^"%~2^" ^"%~3^""
+ call "%JAVA_EXE%" %JAVA_PARAMS% org.apache.nifi.authentication.single.user.command.SetSingleUserCredentials %CREDENTIALS%
+) else if %RUN_COMMAND% == "set-sensitive-properties-key" (
+ call "%JAVA_EXE%" %JAVA_PARAMS% org.apache.nifi.flow.encryptor.command.SetSensitivePropertiesKey %~2
+) else if %RUN_COMMAND% == "set-sensitive-properties-algorithm" (
+ call "%JAVA_EXE%" %JAVA_PARAMS% org.apache.nifi.flow.encryptor.command.SetSensitivePropertiesAlgorithm %~2
+) else (
+ call "%JAVA_EXE%" %JAVA_MEMORY% %JAVA_PARAMS% org.apache.nifi.bootstrap.RunNiFi %RUN_COMMAND%
Review Comment:
The command `stop` seems to be recognized as such by the `RunNiFi` main class, but the `start` and `run` commands seem to behave the same. I expect `start` to spawn the process, and return to the command prompt, where `run` should continue interacting with the console window until the Ctrl+C signal is sent. But both commands remain interactive, and the `stop` command, while writing the expected output to stdout, does not actually stop the process.
```
bin\nifi.cmd stop
JAVA_HOME not defined: using PATH for java command
JAVA_HOME:
NIFI_HOME: ...nifi-1.18.0-SNAPSHOT\bin\..
INFO [main] org.apache.nifi.bootstrap.Command Apache NiFi has accepted the Shutdown Command and is shutting down now
nifi-1.18.0-SNAPSHOT>
```
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.cmd:
##########
@@ -0,0 +1,56 @@
+@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
+
+call %~dp0\nifi-env.cmd
+
+if exist "%JAVA_HOME%\bin\java.exe" (
+ set JAVA_EXE=%JAVA_HOME%\bin\java.exe
+) else (
+ echo JAVA_HOME not defined: using PATH for java command
+ set JAVA_EXE=java
+)
+
+set BOOTSTRAP_LIB_DIR=%NIFI_HOME%\lib\bootstrap
+set CONF_DIR=%NIFI_HOME%\conf
+
+set LOG_DIR_PROPERTY=-Dorg.apache.nifi.bootstrap.config.log.dir=%NIFI_LOG_DIR%
+set PID_DIR_PROPERTY=-Dorg.apache.nifi.bootstrap.config.pid.dir=%NIFI_PID_DIR%
+set CONFIG_FILE_PROPERTY=-Dorg.apache.nifi.bootstrap.config.file=%CONF_DIR%\bootstrap.conf
+set PROPERTIES_FILE_PROPERTY=-Dnifi.properties.file.path=%CONF_DIR%\nifi.properties
+set BOOTSTRAP_HEAP_SIZE=48m
+
+set JAVA_ARGS=%LOG_DIR_PROPERTY% %PID_DIR_PROPERTY% %CONFIG_FILE_PROPERTY% %PROPERTIES_FILE_PROPERTY%
+set JAVA_PARAMS=-cp %BOOTSTRAP_LIB_DIR%\*;%CONF_DIR% %JAVA_ARGS%
+set JAVA_MEMORY=-Xms%BOOTSTRAP_HEAP_SIZE% -Xmx%BOOTSTRAP_HEAP_SIZE%
+
+echo JAVA_HOME: %JAVA_HOME%
+echo NIFI_HOME: %NIFI_HOME%
+echo.
+
+set RUN_COMMAND="%~1"
+if %RUN_COMMAND% == "set-single-user-credentials" (
+ rem Set credentials with quoted arguments passed to Java command
+ set "CREDENTIALS=^"%~2^" ^"%~3^""
+ call "%JAVA_EXE%" %JAVA_PARAMS% org.apache.nifi.authentication.single.user.command.SetSingleUserCredentials %CREDENTIALS%
Review Comment:
I typically run this command on MacOS from $NIFI_ROOT, rather than from $NIFI_ASSEMBLY_DIR:
`./nifi-assembly/target/nifi-1.18.0-SNAPSHOT-bin/nifi-1.18.0-SNAPSHOT/bin/nifi.sh set-single-user-credentials user password`
On Windows, the script works from $NIFI_ASSEMBLY_DIR:
```
nifi\nifi-assembly\target\nifi-1.18.0-SNAPSHOT-bin\nifi-1.18.0-SNAPSHOT>bin\nifi.cmd set-single-user-credentials user password
Login Identity Providers Processed [nifi\nifi-assembly\target\nifi-1.18.0-SNAPSHOT-bin\nifi-1.18.0-SNAPSHOT\.\conf\login-identity-providers.xml]
```
but not from $NIFI_ROOT:
```
nifi>nifi-assembly\target\nifi-1.18.0-SNAPSHOT-bin\nifi-1.18.0-SNAPSHOT\bin\nifi.cmd set-single-user-credentials user password
Exception in thread "main" java.io.UncheckedIOException: Reading Login Identity Providers Failed
at org.apache.nifi.authentication.single.user.writer.StandardLoginCredentialsWriter.readProviders(StandardLoginCredentialsWriter.java:84)
at org.apache.nifi.authentication.single.user.writer.StandardLoginCredentialsWriter.writeLoginCredentials(StandardLoginCredentialsWriter.java:70)
at org.apache.nifi.authentication.single.user.command.SetSingleUserCredentials.setCredentials(SetSingleUserCredentials.java:79)
at org.apache.nifi.authentication.single.user.command.SetSingleUserCredentials.run(SetSingleUserCredentials.java:73)
at org.apache.nifi.authentication.single.user.command.SetSingleUserCredentials.main(SetSingleUserCredentials.java:58)
Caused by: java.nio.file.NoSuchFileException: .\conf\login-identity-providers.xml
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] exceptionfactory commented on a diff in pull request #6370: NIFI-9500 Add nifi.cmd for Windows
Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on code in PR #6370:
URL: https://github.com/apache/nifi/pull/6370#discussion_r968392863
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.cmd:
##########
@@ -0,0 +1,56 @@
+@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
+
+call %~dp0\nifi-env.cmd
+
+if exist "%JAVA_HOME%\bin\java.exe" (
+ set JAVA_EXE=%JAVA_HOME%\bin\java.exe
+) else (
+ echo JAVA_HOME not defined: using PATH for java command
+ set JAVA_EXE=java
+)
+
+set BOOTSTRAP_LIB_DIR=%NIFI_HOME%\lib\bootstrap
+set CONF_DIR=%NIFI_HOME%\conf
+
+set LOG_DIR_PROPERTY=-Dorg.apache.nifi.bootstrap.config.log.dir=%NIFI_LOG_DIR%
+set PID_DIR_PROPERTY=-Dorg.apache.nifi.bootstrap.config.pid.dir=%NIFI_PID_DIR%
+set CONFIG_FILE_PROPERTY=-Dorg.apache.nifi.bootstrap.config.file=%CONF_DIR%\bootstrap.conf
+set PROPERTIES_FILE_PROPERTY=-Dnifi.properties.file.path=%CONF_DIR%\nifi.properties
+set BOOTSTRAP_HEAP_SIZE=48m
+
+set JAVA_ARGS=%LOG_DIR_PROPERTY% %PID_DIR_PROPERTY% %CONFIG_FILE_PROPERTY% %PROPERTIES_FILE_PROPERTY%
+set JAVA_PARAMS=-cp %BOOTSTRAP_LIB_DIR%\*;%CONF_DIR% %JAVA_ARGS%
+set JAVA_MEMORY=-Xms%BOOTSTRAP_HEAP_SIZE% -Xmx%BOOTSTRAP_HEAP_SIZE%
+
+echo JAVA_HOME: %JAVA_HOME%
+echo NIFI_HOME: %NIFI_HOME%
+echo.
+
+set RUN_COMMAND="%~1"
+if %RUN_COMMAND% == "set-single-user-credentials" (
+ rem Set credentials with quoted arguments passed to Java command
+ set "CREDENTIALS=^"%~2^" ^"%~3^""
+ call "%JAVA_EXE%" %JAVA_PARAMS% org.apache.nifi.authentication.single.user.command.SetSingleUserCredentials %CREDENTIALS%
Review Comment:
Thanks for point out this issue @greyp9.
The `SetSingleUserCredentials` command class attempts to resolve the `login-identity-providers.xml` from the current working directory. The `nifi.sh` script changes to the NiFi Home directory prior to running the command, so I updated the `nifi.cmd` to take the same approach, so both approaches described should now work as expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org