Sha256: a23349747e493fa7648af78aa7be116602f71fb37708fd0891ffa99a610b00dd

Contents?: true

Size: 977 Bytes

Versions: 8

Compression:

Stored size: 977 Bytes

Contents

module Soaring
  class Runner
    def initialize(options)
      @options = options
    end

    def run
      Dir.chdir(@options[:project_root]) do
        if @options[:autorestart]
          run_repeatedly
        else
          run_once
        end
      end
    end

    private

    def run_repeatedly
      while true do
        $stderr.puts "starting rackup repeatedly with parameters #{compile_rackup_parameters}" if @options[:verbose]
        response, exit_status = Executor::execute("bundle exec rackup #{compile_rackup_parameters}")
        sleep(0.5)
      end
    end

    def run_once
      $stderr.puts "starting rackup once with parameters #{compile_rackup_parameters}" if @options[:verbose]
      exec("bundle exec rackup #{compile_rackup_parameters}")
    end

    def compile_rackup_parameters
      bind_address = '0.0.0.0'
      rackup_parameters = "-E #{@options[:environment]} ./config.ru -p #{@options[:port]} --host #{bind_address}"
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
soaring-1.0.0 lib/soaring/runner.rb
soaring-0.1.20 lib/soaring/runner.rb
soaring-0.1.19 lib/soaring/runner.rb
soaring-0.1.18 lib/soaring/runner.rb
soaring-0.1.17 lib/soaring/runner.rb
soaring-0.1.16 lib/soaring/runner.rb
soaring-0.1.15 lib/soaring/runner.rb
soaring-0.1.14 lib/soaring/runner.rb