Sha256: 7a6ae742c1c22dfb46cd466dbe76a6e79f69f83ba4db57ac57550f5be8ee351e

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'appengine-sdk'
module Dubious
  module CLI
    class Server < Thor::Group
      SERVLET = AppEngine::SDK::SDK_ROOT + '/lib/shared/servlet-api.jar'
      APIS = AppEngine::SDK::API_JAR
      TOOLS = AppEngine::SDK::TOOLS_JAR
      
      class_option :port,:type=>:numeric,:desc=>'port to run on',:default => 8080
      class_option :address, :type=>:string,:desc => 'address to run on eg localhost',:default => '0.0.0.0'
      
      def start_watcher
        @done=false
        Thread.new do
          until @done
            sleep_time = next_time - Time.now
            sleep(sleep_time) if sleep_time > 0
            next_time = Time.now + 5
            #success = `rake compile:reload`
            #          if 
            puts 'foo'
            sleep 5
          end
        end
        
      end
      
      def start_server   
        
        args = [
          'java', '-cp', TOOLS,
          'com.google.appengine.tools.KickStart',
          'com.google.appengine.tools.development.DevAppServerMain',
          "--address=#{options[:address]}",
          "--port=#{options[:port]}",
          '.']
        system *args
        @done=true
      end
      
      def self.subcommand_help *args
        %Q(Runs the Appengine dev server along with a file watcher that recompiles the app on changes.)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dubious-0.0.3-java lib/dubious/cli/server.rb