Sha256: 2cae40880c3d42c5b73f1f46145a5d01f8227ad75dee9e6a364c02d2687a15af

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

module QPush
  module Server
    # Handles the start of the QPush server via command line
    #
    class Launcher
      def initialize(argv)
        @argv = argv
      end

      # Parses commmand line options and starts the Manager object
      #
      def start
        start_message
        setup_options
        require_jobs
        boot_manager
      end

      private

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

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

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

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

      def require_jobs
        Dir[Dir.pwd + "#{QPush.config.jobs_path}/**/*.rb"].each do |file|
          require file
        end
      end

      def boot_manager
        manager = Manager.new(QPush.config.manager_options)
        manager.start
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qpush-0.1.2 lib/qpush/server/launcher.rb