# File lib/simp/cli/commands/bootstrap.rb, line 335
  def self.ensure_puppetserver_running(port = nil)
    port ||= `puppet config print masterport`.chomp

    begin
      info("Waiting for puppetserver to accept connections on port #{port}", 'cyan')
      curl_cmd = "curl -sS --cert #{::Utils.puppet_info[:config]['certdir']}/`hostname`.pem" +
        " --key #{::Utils.puppet_info[:config]['ssldir']}/private_keys/`hostname`.pem -k -H" +
        " \"Accept: s\" https://localhost:#{port}/production/certificate_revocation_list/ca"
      debug(curl_cmd)
      running = (%x{#{curl_cmd} 2>&1} =~ /CRL/)
      unless running
        system('puppet resource service puppetserver ensure="running" enable=true > /dev/null 2>&1 &')
        stages = ["\\",'|','/','-']
        rest = 0.1
        timeout = 5
        Timeout::timeout(timeout*60) {
          while not running do
            running = (%x{#{curl_cmd} 2>&1} =~ /CRL/)
            stages.each{ |x|
              $stdout.flush
              print "> #{x}\r"
              sleep(rest)
            }
          end
        }
        $stdout.flush
      end
    rescue Timeout::Error
      fail("The Puppet Server did not start within #{timeout} minutes. Please start puppetserver by hand and inspect any issues.")
    end
  end