Github user PuspenduBanerjee commented on a diff in the pull request:
https://github.com/apache/nifi/pull/675#discussion_r72326901
--- Diff:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh
---
@@ -265,20 +265,54 @@ run() {
BOOTSTRAP_DIR_PARAMS="${BOOTSTRAP_LOG_PARAMS} ${BOOTSTRAP_PID_PARAMS}
${BOOTSTRAP_CONF_PARAMS}"
RUN_NIFI_CMD="cd "\""${NIFI_HOME}"\"" && ${sudo_cmd_prefix}
"\""${JAVA}"\"" -cp "\""${BOOTSTRAP_CLASSPATH}"\"" -Xms12m -Xmx24m
${BOOTSTRAP_DIR_PARAMS} org.apache.nifi.bootstrap.RunNiFi"
+ LSB_EXIT_STATUS=0
+ LSB_NIFI_STATUS_TEMPFILE=`mktemp -t
LSB_NIFI_STATUS_TEMPFILE.XXXXXXXXXX`
if [ "$1" = "start" ]; then
(eval $RUN_NIFI_CMD $@ &)
else
- (eval $RUN_NIFI_CMD $@)
+ (eval $RUN_NIFI_CMD $@ "| tee "$LSB_NIFI_STATUS_TEMPFILE)
fi
# Wait just a bit (3 secs) to wait for the logging to finish and then
echo a new-line.
# We do this to avoid having logs spewed on the console after running
the command and then not giving
# control back to the user
sleep 3
echo
+ if [ "$1" = "status" ]; then
+ LSB_EXIT_STATUS= getLSBStatus
+ fi
+ return $LSB_EXIT_STATUS
}
+# Standard Status codes for LSB compliance
+# See:
http://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
+# If the status action is requested, the init script will return the
following exit status codes.
+# 0 program is running or service is OK
+# 1 program is dead and /var/run pid file exists
+# 2 program is dead and /var/lock lock file exists
+# 3 program is not running
+# 4 program or service status is unknown
+# 5-99 reserved for future LSB use
+# 100-149 reserved for distribution use
+# 150-199 reserved for application use
+# 200-254 reserved
+
+getLSBStatus() {
+ LSB_EXIT_STATUS=4
+ if [ `grep -c "not.*running" ${LSB_NIFI_STATUS_TEMPFILE}` -gt 0 ]; then
--- End diff --
Need to see, if that approach is side-effects free. A short term solution
could be getting it done with log parsing. A long term solution could be
creating necessary RunNifi companion because some system relies on systemd
and some on upstart.
Thanks & Regards,
Puspendu Banerjee
On Jul 26, 2016 10:19 AM, "Aldrin Piri" <[email protected]> wrote:
> In
>
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh
> <https://github.com/apache/nifi/pull/675#discussion_r72271118>:
>
> > +# Standard Status codes for LSB compliance
> > +# See:
http://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
> > +# If the status action is requested, the init script will return the
following exit status codes.
> > +# 0 program is running or service is OK
> > +# 1 program is dead and /var/run pid file exists
> > +# 2 program is dead and /var/lock lock file exists
> > +# 3 program is not running
> > +# 4 program or service status is unknown
> > +# 5-99 reserved for future LSB use
> > +# 100-149 reserved for distribution use
> > +# 150-199 reserved for application use
> > +# 200-254 reserved
> > +
> > +getLSBStatus() {
> > + LSB_EXIT_STATUS=4
> > + if [ `grep -c "not.*running" ${LSB_NIFI_STATUS_TEMPFILE}` -gt 0 ];
then
>
> Thinking through this a bit more, what do you think about the NiFi
> application returning an appropriate status code from RunNiFi with a
> System.exit? This would remove ambiguity and avoid the need to grep for
> specific patterns.
>
> â
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
>
<https://github.com/apache/nifi/pull/675/files/5cc306c843b4056845eb483b9581a6b71c326dfc#r72271118>,
> or mute the thread
>
<https://github.com/notifications/unsubscribe-auth/AE2raBdqbbn_mgyCcneRZKMu9jHDoZ-dks5qZiV1gaJpZM4JP4_d>
> .
>
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---