-
Notifications
You must be signed in to change notification settings - Fork 28
/
couchdb.init
131 lines (118 loc) · 3.23 KB
/
couchdb.init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# chkconfig: - 26 74
# description: Starts and stops the CouchDB daemon that handles \
# all database requests.
#
### BEGIN INIT INFO
# Provides: couchdb
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Apache CouchDB, a RESTful document oriented database
# Description: Apache CouchDB is a distributed, fault-tolerant and schema-free
# document-oriented database accessible via a RESTful HTTP/JSON API. Among other
# features, it provides robust, incremental replication with bi-directional
# conflict detection and resolution, and is queryable and indexable using a
# table-oriented view engine with JavaScript acting as the default view
# definition language.
### END INIT INFO
# Author: CouchDB Developers <dev@couchdb.apache.org>
# Source function library.
. /etc/rc.d/init.d/functions
prog=couchdb
exec=/opt/couchdb/bin/$prog
COUCHDB_USER=couchdb
COUCHDB_PIDFILE=/var/run/$prog.pid
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
PID="$(pgrep -u couchdb beam* || true)"
LOCKFILE=/var/lock/subsys/$prog
start() {
[ -x $exec ] || exit 5
echo -n $"Starting $prog: "
status_q && echo -n "already running" && warning && echo && exit 0
daemon --user $COUCHDB_USER \
--pidfile $COUCHDB_PIDFILE \
nohup $exec $COUCHDB_OPTIONS >/dev/null 2>&1 &
retval=$?
[ $retval -eq 0 ] && touch $LOCKFILE && success || failure
echo
return $retval
}
stop() {
echo -n $"Stopping $prog: "
retval=0
if ! status_q ; then
echo -n "already stopped" && warning
else
pkill -u $COUCHDB_USER beam\*
retval=$?
[ $retval -eq 0 ] && rm -f $lockfile && success || failure
fi
echo
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
usage() {
echo "Usage: couchdb {start|stop|status|restart|force-reload}" >&2
}
status() {
pgrep -u couchdb beam* > /dev/null && status="$?" || status="$?"
if [ "$status" = 0 ]; then
echo "$prog is running"
return 0
elif [ "$status" = 4 ]; then
echo "could not access PID file for $prog"
return $status
else
echo "$prog is not running"
return $status
fi
}
status_q() {
status >/dev/null 2>&1
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
reload)
usage
exit 3
;;
force-reload)
reload
;;
restart)
restart
;;
'')
usage
exit 3
;;
esac
exit $?