/usr/lib/ocf/resource.d/heartbeat/SphinxSearchDaemon is in resource-agents 1:3.9.2-5ubuntu4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | #!/bin/sh
#
#
# Searchd OCF RA.
# Manages the Sphinx search daemon
#
# Copyright (c) 2007 Christian Rishoj (christian@rishoj.net)
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like. Any license provided herein, whether implied or
# otherwise, applies only to this software file. Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="SphinxSearchDaemon" version="0.9">
<version>1.0</version>
<longdesc lang="en">
This is a searchd Resource Agent. It manages the Sphinx Search Daemon.
</longdesc>
<shortdesc lang="en">Manages the Sphinx search daemon.</shortdesc>
<parameters>
<parameter name="config" required="0" unique="1">
<longdesc lang="en">
searchd configuration file
</longdesc>
<shortdesc lang="en">Configuration file</shortdesc>
<content type="string" default="/etc/sphinx/sphinx.conf" />
</parameter>
<parameter name="searchd" required="0" unique="0">
<longdesc lang="en">
searchd binary
</longdesc>
<shortdesc lang="en">searchd binary</shortdesc>
<content type="string" default="/usr/local/bin/searchd" />
</parameter>
<parameter name="search" required="0" unique="0">
<longdesc lang="en">
Search binary for functional testing in the monitor action.
</longdesc>
<shortdesc lang="en">search binary</shortdesc>
<content type="string" default="/usr/local/bin/search" />
</parameter>
<parameter name="testQuery" required="0" unique="0">
<longdesc lang="en">
Test query for functional testing in the monitor action.
The query does not need to match any documents in the index.
The purpose is merely to test whether the search daemon is
is able to query its indices and respond properly.
</longdesc>
<shortdesc lang="en">test query</shortdesc>
<content type="string" default="Heartbeat_Monitor_Query_Match_string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20s" />
<action name="stop" timeout="20s" />
<action name="monitor" timeout="20" interval="10" depth="0" />
<action name="meta-data" timeout="5" />
<action name="validate-all" timeout="20s" />
</actions>
</resource-agent>
END
}
#######################################################################
searchd_usage() {
cat <<END
usage: $0 {start|stop|monitor|validate-all|meta-data}
Expects to have a fully populated OCF RA-compliant environment set.
END
}
searchd_start() {
if ! searchd_validate ; then
return $OCF_ERR_GENERIC
fi
if ! searchd_status ; then
$OCF_RESKEY_searchd --config $OCF_RESKEY_config
if [ $? != 0 ]; then
return $OCF_ERR_GENERIC
fi
fi
if searchd_check ; then
return $OCF_SUCCESS
else
return $OCF_ERR_GENERIC
fi
}
searchd_stop() {
if ! searchd_validate ; then
return $OCF_ERR_GENERIC
fi
if searchd_status ; then
$OCF_RESKEY_searchd --config $OCF_RESKEY_config --stop
if [ $? = 0 ]; then
return $OCF_SUCCESS
else
return $OCF_ERR_GENERIC
fi
else
return $OCF_SUCCESS
fi
}
isRunning()
{
kill -s 0 "$1" > /dev/null && [ `ps -p "$1" | grep searchd | wc -l` -eq 1 ]
}
searchd_status() {
pidfile=`grep -v "^#" "$OCF_RESKEY_config" | grep -w pid_file | awk -F "[ \t]*=[ \t]*" '{ print $2 }'`
if [ -f "$pidfile" ] ; then
PID=`head -n 1 $pidfile`
if [ ! -z "$PID" ] ; then
isRunning "$PID"
if [ $? = 0 ] ; then
return 0
fi
fi
fi
false
}
searchd_check() {
$OCF_RESKEY_search --config $OCF_RESKEY_config --noinfo "$OCF_RESKEY_testQuery" > /dev/null
}
searchd_monitor() {
if ! searchd_validate ; then
return $OCF_NOT_RUNNING
fi
if searchd_status ; then
if searchd_check ; then
return $OCF_RUNNING
else
return $OCF_ERR_GENERIC
fi
else
return $OCF_NOT_RUNNING
fi
}
searchd_validate() {
if [ ! -x "$OCF_RESKEY_search" ]; then
ocf_log err "search binary '$OCF_RESKEY_search' does not exist or cannot be executed"
return $OCF_ERR_ARGS
fi
if [ ! -x "$OCF_RESKEY_searchd" ]; then
ocf_log err "searchd binary '$OCF_RESKEY_searchd' does not exist or cannot be executed"
return $OCF_ERR_ARGS
fi
if [ ! -f "$OCF_RESKEY_config" ]; then
ocf_log err "config file '$OCF_RESKEY_config' does not exist"
return $OCF_ERR_ARGS
fi
return $OCF_SUCCESS
}
: ${OCF_RESKEY_config=/etc/sphinx/sphinx.conf}
: ${OCF_RESKEY_search=/usr/local/bin/search}
: ${OCF_RESKEY_searchd=/usr/local/bin/searchd}
: ${OCF_RESKEY_testQuery=Heartbeat_Monitor_Query_Match_string}
case $__OCF_ACTION in
meta-data) meta_data
exit $OCF_SUCCESS
;;
start) searchd_start;;
stop) searchd_stop;;
monitor) searchd_monitor;;
validate-all) searchd_validate;;
usage|help) searchd_usage
exit $OCF_SUCCESS
;;
*) searchd_usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
rc=$?
ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
exit $rc
|