def start

      unless @allow_multiple
        if running?
          log(:error, "\"#{@name}\" is already running (PID: #{@pid})")
          return
        end
      end

      @pid = fork do
        begin
          Process.setsid

          open(@pid_file, 'w') do |f|
            f << Process.pid
            @pid = Process.pid
          end

          execute_callback(:before_start)

          Dir.chdir @path.to_s
          File.umask 0000

          if @logger
            log = File.new(@log_file, "a")
            log.sync = @sync_log

            STDIN.reopen "/dev/null"
            STDOUT.reopen log
            STDERR.reopen STDOUT
          end

          trap("TERM") do
            stop
          end

          execute_callback(:start)

        rescue RuntimeError => message
          STDERR.puts message
          STDERR.puts message.backtrace

          execute_callback(:error)
        rescue => message
          STDERR.puts message
          STDERR.puts message.backtrace

          execute_callback(:error)
        end
      end

    rescue => message
      STDERR.puts message
      STDERR.puts message.backtrace
      execute_callback(:error)
    end
def start

      unless @allow_multiple
        if running?
          log(:error, "\"#{@name}\" is already running (PID: #{@pid})")
          return
        end
      end

      @pid = fork do
        begin
          Process.setsid

          open(@pid_file, 'w') do |f|
            f << Process.pid
            @pid = Process.pid
          end

          execute_callback(:before_start)

          Dir.chdir @path.to_s
          File.umask 0000

          if @logger
            log = File.new(@log_file, "a")
            log.sync = @sync_log

            STDIN.reopen "/dev/null"
            STDOUT.reopen log
            STDERR.reopen STDOUT
          end

          trap("TERM") do
            stop
          end

          execute_callback(:start)

        rescue RuntimeError => message
          STDERR.puts message
          STDERR.puts message.backtrace

          execute_callback(:error)
        rescue => message
          STDERR.puts message
          STDERR.puts message.backtrace

          execute_callback(:error)
        end
      end

    rescue => message
      STDERR.puts message
      STDERR.puts message.backtrace
      execute_callback(:error)
    end
Start

 Validate callbacks and start daemon