# File lib/picnic/service_control.rb, line 155
    def start
      # use local app bin if it exists and is executable -- makes debugging easier
      bin = options[:bin_file]

      if File.exists?(bin)
        exec = "ruby #{bin}"
      else
        exec = app
      end
      
      case get_state
      when :ok
        $stderr.puts "#{app} is already running"
        exit 1
      when :not_running, :empty_pid
        $stderr.puts "The pid file '#{@options[:pid_file]}' exists but #{app} is not running." +
          " The pid file will be automatically deleted for you, but this shouldn't have happened!"
        File.delete(@options[:pid_file])
      when :dead
        $stderr.puts "The pid file '#{@options[:pid_file]}' exists but #{app} is not running." +
          " Please delete the pid file first."
        exit 1
      when :missing_pid
        # we should be good to go (unless the server is already running without a pid file)
      else
        $stderr.puts "#{app} could not be started. Try looking in the log file for more info."
        exit 1
      end
        
      cmd = "#{exec} -d -P #{@options[:pid_file]}"
      cmd += " -c #{@options[:conf_file]}" if !@options[:conf_file].nil?
      
      puts "<<< #{cmd}" if @options[:verbose]
      
      output = `#{cmd}`
      
      puts ">>> #{output}" if @options[:verbose]
      
      s = get_state
      
      puts ">>> STATE: #{s.to_s}" if options[:verbose]
      
      if s == :ok
        exit 0
      else
        $stderr.puts "\n#{app} could not start properly!\nTry running with the --verbose option for details." 
        case s
        when :missing_pid
          exit 4
        when :not_running
          exit 3
        when :dead
          exit 1
        else
          exit 4
        end
      end
    end