Supervisord

Supervisord 執行 ssserver 但在 CentOS 上報錯?

  • September 12, 2015

我有以下 Supervisord 設置/etc/supervisord.conf

...
[program:shadowsocks]
command=ssserver -c ~/config.json
autorestart=true
user=nobody
...

/etc/rc.d/init.d/supervisord:

#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord

# Source init functions
. /etc/rc.d/init.d/functions

prog="supervisord"

prefix="/usr/"
exec_prefix="${prefix}"
prog_bin="${exec_prefix}/bin/supervisord"
PIDFILE="/var/run/$prog.pid"

start()
{
      echo -n $"Starting $prog: "
      daemon $prog_bin --pidfile $PIDFILE
      [ -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup"
      echo
}

stop()
{
      echo -n $"Shutting down $prog: "
      [ -f $PIDFILE ] && killproc $prog || success $"$prog shutdown"
      echo
}

case "$1" in

start)
  start
;;

stop)
  stop
;;

status)
      status $prog
;;

restart)
  stop
  start
;;

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

esac

然後我執行以下操作來設置並啟動它:

$ sudo chmod +x /etc/rc.d/init.d/supervisord
$ sudo chkconfig --add supervisord
$ sudo chkconfig supervisord on
$ sudo service supervisord start

之後一切正常。現在當我開始時shadowsocks

supervisorctl start shadowsocks

它報告一個錯誤:

shadowsocks: ERROR (abnormal termination)

但是,如果我直接執行:

ssserver -c ~/config.json

它運作良好。為什麼這不起作用supervisord

supervisor不支持 tidle~擴展的AFAIK~/config.json被視為文字。

您應該更改~/config.json為它的絕對路徑/path/to/config.json並確保它可以被nobody.

有關主管配置的更多資訊,請參見此處

引用自:https://unix.stackexchange.com/questions/140774