停止/重启Gearmand

时间:2015-03-18 00:28:31

标签: php ubuntu server jobs gearman

我已将Gearman Job Server(aka Gearmand)1.0.6安装到我的Ubuntu:

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:        14.04

我还安装了gearman-tools,libgearman-dev。 enter image description here 尝试使用命令重新启动Gearmand:

/etc/init.d/gearman-job-server restart

但是我收到了一个错误:

 No /usr/sbin/gearmand found running; none killed.
 /usr/sbin/gearmand already running.

enter image description here

当我试图阻止它时,同样的事情发生了:

/etc/init.d/gearman-job-server stop

回复:No /usr/sbin/gearmand found running; none killed.

/etc/init.d/gearman-job-server代码是:

#!/bin/sh

# Gearman server and library
# Copyright (C) 2008 Brian Aker, Eric Day
# All rights reserved.
#
# Use and distribution licensed under the BSD license.  See
# the COPYING file in this directory for full text.

### BEGIN INIT INFO
# Provides:          gearman-job-server
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $network $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable gearman job server
### END INIT INFO

prefix=/usr
exec_prefix=${prefix}
NAME=gearmand
DAEMON=${exec_prefix}/sbin/gearmand
PIDDIR=/var/run/gearman
PIDFILE=${PIDDIR}/gearmand.pid
GEARMANUSER="gearman"
PARAMS=""

test -x ${DAEMON} || exit 0

. /lib/lsb/init-functions

test -f /etc/default/gearman-job-server && . /etc/default/gearman-job-server

start()
{
  log_daemon_msg "Starting Gearman Server" "gearmand"
  if ! test -d ${PIDDIR}
  then
    mkdir ${PIDDIR}
    chown ${GEARMANUSER} ${PIDDIR}
  fi
  if start-stop-daemon \
    --start \
    --exec $DAEMON \
    -- --pid-file=$PIDFILE \
       --user=$GEARMANUSER \
       --daemon \
       --log-file=/var/log/gearman-job-server/gearman.log \
       $PARAMS 
  then
    log_end_msg 0
  else
    log_end_msg 1
    log_warning_msg "Please take a look at the syslog"
    exit 1
  fi
}

stop()
{
  log_daemon_msg "Stopping Gearman Server" "gearmand"
  if start-stop-daemon \
    --stop \
    --oknodo \
    --exec $DAEMON \
    --pidfile $PIDFILE
  then
    log_end_msg 0
  else
    log_end_msg 1
    exit 1
  fi
}

status()
{
    status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
}

case "$1" in

  start)
    start
  ;;

  stop)
    stop
  ;;

  status)
    status
  ;;

  restart|force-reload)
    stop
    start
  ;;

  *)
    echo "Usage: $0 {start|stop|restart|force-reload|status}"
  ;;

esac
谷歌没有帮助......也许是以错误的方式搜索。你能帮我把它弄好吗? :)

2 个答案:

答案 0 :(得分:3)

好的,我找到了解决问题的方法。我发现Gearman有很多错误。问题是它没有创建PID表格upstart并且没有使用/etc/default/gearman-job-server的配置。希望它会对某人有所帮助。 将/etc/init/gearman-job-server.conf修改为:

# -*- upstart -*-

# Upstart configuration script for "gearman-job-server".

description "gearman job control server"

start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]

respawn
expect fork

pre-start script
    mkdir -p -m 0775 /var/run/gearman
    chown gearman:gearman /var/run/gearman
end script

script
    . /etc/default/gearman-job-server
    exec start-stop-daemon --start --exec /usr/sbin/gearmand -- $PARAMS
end script

答案 1 :(得分:0)

在停止功能的 /etc/init.d/gearman-server 中执行以下操作:

#  if start-stop-daemon \
#    --stop \
#    --oknodo \
#    --exec $DAEMON \
#    --pidfile $PIDFILE
  if /usr/local/bin/gearadmin --shutdown