0

sudo ./starling start works well but sudo service starling start fails

$ 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>'

The error above is 'cannot find gem starling'

Following the starling file(located in /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

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

Update:

See the answer of sudo ./starling start works well but sudo service starling start fails

Keating
  • 101
  • 3
  • see the answer of [sudo ./starling start works well but sudo service starling start fails][1] [1]: http://stackoverflow.com/questions/9848526/sudo-starling-start-works-well-but-sudo-service-starling-start-fails – Keating Mar 25 '12 at 00:02

1 Answers1

1

Check your environment variables.

Make a copy of the init.d script and rework it to print the output of "env" instead of starting the daemon.

Compare that to what you get when you run "sudo env" from the shell.

Odds are, the answer will be evident in that some required variable/value which IS in the output of "sudo env" will not be in the output of "service starlingenv start" or similar.

ALSO - don't leave your init script 777 unless no-one else EVER logs in on your computer - that's an easy way for a hacker to own you, since root runs that script and ANYONE can change it.

pbr
  • 206
  • 1
  • 3
  • Thank you. I think it lacks the variable GEM_PATH when running `sudo service starling start`. But after I put 'GEM_PATH=/home/keating/.rvm/gems/ruby-1.9.2-p290' in the file, `env | grep GEM_PATH` still echo nothing when run the service command. – Keating Mar 24 '12 at 03:20
  • you have to export the variable to get it into the environment. Just setting the variable sets it only to the shell script - not as part of the environment of processes the script runs. Use "export GEM_PATH=/home/..." rather than just "GEM_PATH=/home/..." – pbr Apr 08 '12 at 22:16
  • Finally, I know there isn't an error about the system variable, but the way I use rvm is not right. Anyway, thank you pbr. – Keating Apr 09 '12 at 05:17