Sha256: 62035b6756a0831d60f7b886fd5271fd765fa617ed65483c3b89250a8707b0af

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

module ActiveHook
  module App
    # Handles the start of the ActiveHook web via command line
    #
    class Launcher
      def initialize(argv)
        @argv = argv
        @puma_config = nil
      end

      def start
        start_message
        setup_options
        boot_puma
      end

      private

      def start_message
        ActiveHook.log.info('ActiveHook App starting!')
        ActiveHook.log.info("* Version #{VERSION}, codename: #{CODENAME}")
      end

      # Parses the arguments passed through the command line.
      #
      def setup_options
        parser = OptionParser.new do |o|
          o.banner = 'Usage: bundle exec bin/activehook [options]'

          o.on('-c', '--config PATH', 'Load PATH for config file') do |arg|
            load(arg)
            ActiveHook.log.info("* App config:  #{arg}")
          end

          o.on('-p', '--puma config PATH', 'Load PATH for puma config file') do |arg|
            @puma_config = arg
            ActiveHook.log.info("* Puma config: #{arg}")
          end

          o.on('-h', '--help', 'Prints this help') { puts o && exit }
        end
        parser.parse!(@argv)
      end

      def boot_puma
        ActiveHook.log.info('* Booting Puma...')
        exec("bundle exec puma -C #{@puma_config} --dir lib/activehook/app/")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
activehook-0.1.9 lib/activehook/app/launcher.rb
activehook-0.1.8 lib/activehook/app/launcher.rb
activehook-0.1.7 lib/activehook/app/launcher.rb
activehook-0.1.6 lib/activehook/app/launcher.rb
activehook-0.1.5 lib/activehook/app/launcher.rb
activehook-0.1.4 lib/activehook/app/launcher.rb
activehook-0.1.3 lib/activehook/app/launcher.rb