#211 ✓hold
Chad Woolley

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

Reported by Chad Woolley | August 23rd, 2008 @ 06:20 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:07 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.

  • Chad Woolley

    Chad Woolley May 11th, 2009 @ 05:48 PM

    • Assigned user set to “Chad Woolley”
    • State changed from “new” to “hold”

    Not sure how this relates to the latest daemon_helper, which has been modified significantly. Are changes still needed? Please advise...

  • Mischa The Evil

    Mischa The Evil May 11th, 2009 @ 07:14 PM

    https://cruisecontrolrb.lighthou... seems implemented by your recent changes... Nice!

    https://cruisecontrolrb.lighthou... does not seem to be implemented. I wanted to be able to print the status of the daemon (by looking for it's master-PID) to the console. Since I run CCRB on a RHEL-derivative (which provides support for the "service"-command (a sort-of wrapper around the bare init-scripts) I wanted to implement support for a command like "service ccrb status" (where ccrb is the name of the service derived from the init.d-script name) which checks for any PID-files (master and builders) and returns a message (with master-pid id) according to the result.

    Though plz note that this might be a niche-thingy which does not suite the masses... Let me know if you need more feedback...

    Regards...

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

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

Referenced by

Pages