sudo ./starling start 运行良好,但 sudo service starling start 失败

sudo ./starling start 运行良好,但 sudo service starling start 失败

sudo ./starling start效果很好但sudo service starling start失败了

$ sudo ./starling start
 * Starting Starling Server...                  [ OK ] 
$ sudo ./starling stop
 * Stop Starling Server...                  [ OK ] 
$ sudo service starling stop
 * Starting Starling Server...                                        
/home/keating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in
`to_specs': Could not find starling (>= 0) amongst [minitest-1.6.0,
rake-0.8.7, rdoc-2.5.8] (Gem::LoadError)    from
/home/keating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in
`to_spec'   from
/home/keating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1229:in
`gem'   from /home/keating/.rvm/gems/ruby-1.9.2-p290/bin/starling:18:in
`<main>'

上面的错误是“找不到 gem starling”

遵循starling文件(位于/etc/init.d,rwxrwxrwx):

set -e
LOGFILE=/var/log/starling/starling.log SPOOLDIR=/var/spool/starling
PORT=22122 LISTEN=127.0.0.1 PIDFILE=/var/run/starling.pid



NAME=starling DESC="Starling"
INSTALL_DIR=/home/keating/.rvm/gems/ruby-1.9.2-p290/bin/
DAEMON=$INSTALL_DIR/$NAME SCRIPTNAME=/etc/init.d/$NAME
OPTS="-d"

. /lib/lsb/init-functions


d_start() {
        log_begin_msg "Starting Starling Server..."
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $OPTS || log_end_msg 1
        log_end_msg 0 }

d_stop() {
        log_begin_msg "Stopping Starling Server..."
        start-stop-daemon --stop --quiet --pidfile $PIDFILE || log_end_msg 1
        log_end_msg 0 }

case "$1" in start) d_start ;; stop) d_stop ;;
restart|force-reload|reload) d_stop sleep 2 d_start ;;
*) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" exit 3 ;; esac

exit 0

-----------------------------------------------------------------

更新:

参见 sudo ./starling start 运行良好,但 sudo service starling start 失败

答案1

检查你的环境变量。

复制 init.d 脚本并重新编写它以打印“env”的输出而不是启动守护进程。

将其与从 shell 运行“sudo env”时得到的结果进行比较。

很可能,答案是显而易见的,因为“sudo env”输出中的一些必需变量/值不会出现在“service starlingenv start”或类似输出中。

另外 - 除非没有其他人登录您的计算机,否则不要将您的初始化脚本保留为 777 - 这对黑客来说是一种很容易控制您的方法,因为 root 运行该脚本并且任何人都可以更改它。

相关内容