#211 new
Chad Woolley

Daemon init script having a 'stop' error on clean reboot

Reported by Chad Woolley | August 23rd, 2008 @ 06:19 PM

getting 'stop' error in ~/ccrb/log/cruise_daemon_err.log even on clean reboot.

Comments and changes to this ticket

  • Mischa The Evil

    Mischa The Evil October 16th, 2008 @ 06:08 AM

    Chad,

    I've modified the daemon_helper.rb to solve this issue. The stop-method now looks like this:

    
    def stop_cruise
      failed = false
      failed ||= !(system(su_if_needed("mongrel_rails stop -P #{CRUISE_HOME}/tmp/pids/mongrel.pid")))
      Dir["#{CRUISE_HOME}/tmp/pids/builders/*.pid"].each do |pid_file|
        pid = File.open(pid_file){|f| f.read }
        failed ||= !(system(su_if_needed("kill -9 #{pid}")))
        rm pid_file
      end
      if failed
        log(:err, "'stop' command failed")
        exit 1
      else
        exit 0
      end
    end
    

    The method was missing the calls through su_if_needed().

    HTH...

  • Chad Woolley
  • Mischa The Evil

    Mischa The Evil October 16th, 2008 @ 08:53 AM

    Btw: I've also added a new handler in the daemon_helper.rb-file to be able to request the daemon's status on a RHEL-box combined with the "service"-command.

    The new method looks like this:

    
    def status_cruise
      running = false
      masterpid = 0
    
      Dir["#{CRUISE_HOME}/tmp/pids/*.pid"].each do |mongrel_pid_file|
        running ||= File.open(mongrel_pid_file)
        masterpid = File.open(mongrel_pid_file){|f| f.read }
      end
    
      Dir["#{CRUISE_HOME}/tmp/pids/builders/*.pid"].each do |builder_pid_file|
        running ||= File.open(builder_pid_file)
      end
    
      if running
        print "CruiseControl.rb started with PID: #{masterpid}...\n"
        exit 1
      else
        print "CruiseControl.rb not started...\n"
        exit 0
      end
    end
    

    To reflect the new handler in the init script I modified it to something like:

    
    command = ARGV.shift
    case command
    when 'start'
      start_cruise "cd #{CRUISE_HOME} && ./cruise start -d"
    when 'stop'
      stop_cruise
    when 'status'
      status_cruise
    else
      p "Usage: #{File.dirname(__FILE__)} start|stop|status"
      exit 1
    end
    

    Again, HTH... Btw: I'll take a look at a way to create a restart-handler in the init-script also in near future.

  • Chad Woolley

    Chad Woolley October 16th, 2008 @ 09:24 AM

    Mischa,

    Thanks again for your work on this.

    FYI - If you fork cruisecontrol.rb on github and make your changes there, it will be much easier for people to test and apply your patches, instead of just pasting the text in here.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket