[ 
https://issues.apache.org/jira/browse/NIFI-2199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16007206#comment-16007206
 ] 

ASF GitHub Bot commented on NIFI-2199:
--------------------------------------

GitHub user apiri opened a pull request:

    https://github.com/apache/nifi/pull/1786

    NIFI-2199 & NIFI-3112 - Handle propagation of stderr and allow ssh restart

    NIFI-2199
    NIFI-3112
    Pipe stdout to /dev/null and allow stderr to propagate through.
    
    This correction does not make NiFi fully LSB spec compliant but does solve 
the two issues presented in the listed tickets.  This will allow stderr to 
propagate through and restart through SSH.
    
    ssh can be tested by issuing a 
    `ssh user@remote-host <path to nifi>/bin/nifi.sh restart`
    from a local machine to a remote host
    
    3112 can be verified by changing a property to bootstrap causing it to be 
invalid and running the above.  As listed in the prior discussion of 3112, 
making `graceful.shutdown.seconds` a negative number such as below:
    > graceful.shutdown.seconds=-20
    
    Will cause an error to be triggered and the appropriate contents 
transmitted.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/apiri/incubator-nifi nifi-2199

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/1786.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1786
    
----
commit 1273e4c60527993385a95b4df3428d1d24bca342
Author: Aldrin Piri <[email protected]>
Date:   2017-05-11T20:35:16Z

    NIFI-2199
    NIFI-3112
    Pipe stdout to /dev/null and allow stderr to propagate through.

----


> NiFi cannot be restarted through SSH (nifi.sh hangs)
> ----------------------------------------------------
>
>                 Key: NIFI-2199
>                 URL: https://issues.apache.org/jira/browse/NIFI-2199
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.0.0, 0.5.1, 0.7.0, 0.6.1, 1.2.0
>            Reporter: Michal Klempa
>            Assignee: Aldrin Piri
>            Priority: Minor
>              Labels: initscript
>             Fix For: 1.1.0, 1.3.0
>
>
> When NiFi is to restarted using SSH from remote host, nifi.sh causes SSH to 
> hang on open io streams.
> Steps to reproduce:
> 1. HostA - NiFi instalation
> 2. HostB - client machine
> 3. log to HostB
> 4. issue a command
> {code}
> ssh root@HostA /etc/init.d/nifi restart
> {code}
> Expected behavior: NiFi is restarted, SSH command exits with 0
> Actual behavior: NiFi is restarted, SSH command hang on
> This seems to be somehow related to SSH handling IO streams of process. Seems 
> like detached NiFi java process does not close stdin/out/err (i do not know 
> precisely) leading to sshd waiting for some input/output to come to client.
> I was able to do a quick&dirty fix in nifi.sh as follows:
> 1. on existing nifi installation, in file /etc/init.d/nifi find the line
> {code}
> (cd "${NIFI_HOME}" && ${sudo_cmd_prefix} "${JAVA}" -cp 
> "${BOOTSTRAP_CLASSPATH}" -Xms12m -Xmx24m 
> -Dorg.apache.nifi.bootstrap.config.file="${BOOTSTRAP_CONF}" 
> org.apache.nifi.bootstrap.RunNiFi $@ &)
> {code}
> its line number 214 (true branch of if [ "$1"] = "start"] condition).
> 2. replace it by line:
> {code}
> (cd "${NIFI_HOME}" && ${sudo_cmd_prefix} "${JAVA}" -cp 
> "${BOOTSTRAP_CLASSPATH}" -Xms12m -Xmx24m 
> -Dorg.apache.nifi.bootstrap.config.file="${BOOTSTRAP_CONF}" 
> org.apache.nifi.bootstrap.RunNiFi $@ > /dev/null 2>&1 < /dev/null &)
> {code}
> This simply redirects stdin from /dev/null to NiFi java process and redirects 
> stdout/err to /dev/null letting SSH to close the session.
> After applying this fix, I am able to restart NiFi remotely using SSH.
> Use case for this scenario: When Flow Manager develop flow.xml.gz on 
> localhost/testing environments, usually deployment to production environment 
> is handled by jenkins/bamboo CI tools. These tools need to log in, upload new 
> flow.xml.gz and restart NiFi. All remotely using SSH.
> If somebody can advice me where in the source code is this line of code 
> located, I can prepare a pull request for this quick&dirty fix.
> But. Maybe we may want to go further and investigate what to do with IO 
> streams inside Java...



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to