[
https://issues.apache.org/jira/browse/SOLR-9769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16825866#comment-16825866
]
Jiri Pejchal commented on SOLR-9769:
------------------------------------
> If Solr is already stopped, and you try to stop it again, that is actually an
>error condition. The script cannot complete the requested action ... so one
>way of interpreting that is an error.
Yes, but you can also look at it from a different angle:
What should be considered a success when calling {{stop}}? When I am calling
stop I want to make sure that solr is not running. That is the state i want to
transition to. So when solr is not running after calling {{stop}} that is a
success. When after calling {{stop}} solr is still running that is a failure.
> Perhaps what should happen here is the exit code should be 1 if Solr is
> already stopped, and 2 or higher if there's something that could be
> classified as more of a "real" problem.
Is there a convention for return codes? I think ideally solr init script should
have the same behaviour as other init scripts. I was able to find Linux
Standard Base conventions for init scripts that states:
_running stop on a service already stopped or not running should be considered
successful and return code should be 0 (zero)._
When greping the scripts in the directory {{/etc/init.d}} for exit codes it
seems to me that zero exit statuses are returned for already stopped services
(at least on debian).
It seems to me that also systemd services behaves this way:
{code}
$ systemctl stop chronyd.service && echo $?
0
$ systemctl stop chronyd.service && echo $?
0
{code}
> As a workaround ...
My problem is actually that my deploy script calls {{solr stop}} and is failing
when solr is stopped.
> solr stop on a service already stopped should return exit code 0
> ----------------------------------------------------------------
>
> Key: SOLR-9769
> URL: https://issues.apache.org/jira/browse/SOLR-9769
> Project: Solr
> Issue Type: Bug
> Security Level: Public(Default Security Level. Issues are Public)
> Components: scripts and tools
> Affects Versions: 6.3
> Reporter: Jiří Pejchal
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> According to the LSB specification
> https://refspecs.linuxfoundation.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic.html#INISCRPTACT
> running stop on a service already stopped or not running should be
> considered successful and return code should be 0 (zero).
> Solr currently returns exit code 1:
> {code}
> $ /etc/init.d/solr stop; echo $?
> Sending stop command to Solr running on port 8983 ... waiting up to 180
> seconds to allow Jetty process 4277 to stop gracefully.
> 0
> $ /etc/init.d/solr stop; echo $?
> No process found for Solr node running on port 8983
> 1
> {code}
> {code:title="bin/solr"}
> if [ "$SOLR_PID" != "" ]; then
> stop_solr "$SOLR_SERVER_DIR" "$SOLR_PORT" "$STOP_KEY" "$SOLR_PID"
> else
> if [ "$SCRIPT_CMD" == "stop" ]; then
> echo -e "No process found for Solr node running on port $SOLR_PORT"
> exit 1
> fi
> fi
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]