Kouhei Sutou
null+****@clear*****
Fri Sep 5 17:11:00 JST 2014
Kouhei Sutou 2014-09-05 17:11:00 +0900 (Fri, 05 Sep 2014) New Revision: 4354fe251659f338ec685c6d83b54598061ac8cf https://github.com/groonga/groonga/commit/4354fe251659f338ec685c6d83b54598061ac8cf Message: deb: use nginx style init script Don't control via HTTP. Use signal. Modified files: packages/debian/groonga-httpd.default packages/debian/groonga-httpd.init Modified: packages/debian/groonga-httpd.default (+1 -11) =================================================================== --- packages/debian/groonga-httpd.default 2014-09-05 17:06:53 +0900 (b95fd7e) +++ packages/debian/groonga-httpd.default 2014-09-05 17:11:00 +0900 (2d23f1e) @@ -1,15 +1,5 @@ # Default -#USER=groonga -#GROUP=groonga -#ADDRESS=127.0.0.1 -#PORT=10041 -#DATABASE=/var/lib/groonga/db/db -#LOG_PATH=/var/log/groonga/groonga.log -#QUERY_LOG_PATH=/var/log/groonga/query.log -#PROTOCOL=http -#GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE=/usr/share/groonga/synonyms.tsv +#GROONGA_HTTPD_ARGS="" TIMEOUT=3 # Comment out this to disable groonga-httpd daemon. ENABLE=yes -# Set "no" to disable to skip updating column for same value. -GRN_JA_SKIP_SAME_VALUE_PUT=yes Modified: packages/debian/groonga-httpd.init (+17 -48) =================================================================== --- packages/debian/groonga-httpd.init 2014-09-05 17:06:53 +0900 (ad8eb26) +++ packages/debian/groonga-httpd.init 2014-09-05 17:11:00 +0900 (b3cba59) @@ -15,23 +15,16 @@ # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC="a HTTP server for groonga which provides full-text search engine and column store" +DESC="a HTTP server for Groonga which provides full-text search engine and column store" NAME=groonga-httpd DAEMON=/usr/sbin/$NAME DAEMON_RESTART=/usr/sbin/$NAME-restart -CURL=/usr/bin/curl -USER=groonga -GROUP=groonga -ADDRESS=127.0.0.1 -PORT=10041 -PIDFILE=/var/run/groonga/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME -OPTION_ARGS="" +GROONGA_HTTPD_ARGS="" START_STOP_DAEMON_ARGS="" ENABLE="no" -TIMEOUT=5 -DEFAULT_FILE=/etc/default/groonga-httpd +DEFAULT_FILE=/etc/default/$NAME # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 @@ -41,25 +34,6 @@ DEFAULT_FILE=/etc/default/groonga-httpd [ "$ENABLE" = "yes" ] || exit 0 -export GRN_JA_SKIP_SAME_VALUE_PUT="$GRN_JA_SKIP_SAME_VALUE_PUT" - -mkdir -p $(dirname ${PIDFILE}) - -if [ -n "${USER}" ]; then - if ! getent passwd | grep -q "^${USER}:"; then - echo "$0: user for running groonga-httpd doesn't exist: ${USER}" >&2 - exit 1 - fi -fi -if [ -n "${GROUP}" ]; then - if ! getent group | grep -q "^${GROUP}:"; then - echo "$0: group for running groonga-httpd doesn't exist: ${GROUP}" >&2 - exit 1 - fi -fi -DAEMON_ARGS="${DAEMON_ARGS} ${OPTION_ARGS}" - - # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh @@ -67,15 +41,12 @@ DAEMON_ARGS="${DAEMON_ARGS} ${OPTION_ARGS}" # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions -send_command() -{ - command=$1 - if [ "$command" = "status" ]; then - $CURL --max-time $TIMEOUT "http://${ADDRESS}:${PORT}/d/${command}" - else - $CURL "http://${ADDRESS}:${PORT}/d/${command}" - fi -} +if [ -z "$PID_FILE" ]; then + PID_FILE=$(grep '^\s*pid\s' /etc/nginx/nginx.conf | sed -re 's/^\s*pid\s+(.+);$/\1/g' | head -n1) + if [ -z "$PID_FILE" ]; then + PID_FILE=/run/groonga-httpd.pid + fi +fi # # Function that starts the daemon/service @@ -86,10 +57,10 @@ do_start() # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \ + start-stop-daemon --start --quiet --pidfile $PID_FILE --exec $DAEMON \ ${START_STOP_DAEMON_ARGS} --test > /dev/null || return 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \ - ${START_STOP_DAEMON_ARGS} -- $DAEMON_ARGS || return 2 + start-stop-daemon --start --quiet --pidfile $PID_FILE --exec $DAEMON \ + ${START_STOP_DAEMON_ARGS} -- $GROONGA_HTTPD_ARGS || return 2 # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend # on this one. As a last resort, sleep for some time. @@ -106,10 +77,8 @@ do_stop() # 2 if daemon could not be stopped # other if a failure occurred - $DAEMON -s stop - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \ - --pidfile $PIDFILE --name $NAME + --pidfile $PID_FILE --name $NAME RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 # Wait for children to finish too if this is a daemon that forks @@ -121,7 +90,7 @@ do_stop() start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON [ "$?" = 2 ] && return 2 # Many daemons don't delete their pidfiles when they exit. - rm -f $PIDFILE + rm -f $PID_FILE return "$RETVAL" } @@ -134,12 +103,12 @@ do_reload() { # restarting (for example, when it is sent a SIGHUP), # then implement that here. # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + start-stop-daemon --stop --signal HUP --quiet --pidfile $PID_FILE --name $NAME return 0 } do_status() { - send_command status + status_of_proc -p $PID_FILE "$DAEMON" "$NAME" return $? } @@ -167,7 +136,7 @@ case "$1" in ;; restart) log_daemon_msg "Restarting $DESC" "$NAME" - if [ -f ${PIDFILE} ]; then + if [ -f ${PID_FILE} ]; then $DAEMON_RESTART else do_start -------------- next part -------------- HTML����������������������������...Download