I'm researching this. Part of the issue being addressed here is that
sometimes, even if the pid file is removed, the process is running.
Testing if the pid file exists is guaranteed to fail in these
situations, and return a successful exit, when no such thing happens. I
may just need to grep ps output :(
Wendall
On 06/16/2013 02:28 AM, Jan Lehnardt wrote:
Wendall (again, sorry :)
BSD (&& Mac OS X) kill doesn’t support the `kill -0` option to test whether
one can send a signal to a PID. Hence `couchdb -d` no longer works on BSD/Mac.
Is there a more portable version of what we are trying to do?
Best
Jan
--
On Mar 18, 2013, at 17:12 , [email protected] wrote:
Fix for COUCHDB-1449 stopped status returned before couchdb process exits.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/15c1a97e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/15c1a97e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/15c1a97e
Branch: refs/heads/master
Commit: 15c1a97e42c5bafad6f5fa83d753d3a7cf64d6d7
Parents: f36232c
Author: Wendall Cada <[email protected]>
Authored: Mon Mar 11 12:05:34 2013 -0700
Committer: Jan Lehnardt <[email protected]>
Committed: Mon Mar 18 17:12:08 2013 +0100
----------------------------------------------------------------------
bin/couchdb.tpl.in | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/15c1a97e/bin/couchdb.tpl.in
----------------------------------------------------------------------
diff --git a/bin/couchdb.tpl.in b/bin/couchdb.tpl.in
index 8b2581a..ff06007 100644
--- a/bin/couchdb.tpl.in
+++ b/bin/couchdb.tpl.in
@@ -288,12 +288,20 @@ EOF
stop_couchdb () {
PID=`_get_pid`
+ STOP_TIMEOUT=60
if test -n "$PID"; then
- if test "$1" = "false"; then
- echo > $PID_FILE
- fi
if kill -0 $PID 2> /dev/null; then
- if kill -1 $PID 2> /dev/null; then
+ if kill -TERM $PID 2> /dev/null; then
+ count=0
+ while kill -0 $PID 2> /dev/null; do
+ if [ $count -ge $STOP_TIMEOUT ]; then
+ echo "Apache CouchDB failed to shutdown."
+ return $SCRIPT_ERROR
+ else
+ count=$[count+1]
+ sleep 1
+ fi
+ done
if test "$1" = "false"; then
echo "Apache CouchDB has been shutdown."
else