Sha256: ab021f9a910da1b5cae8089f674d09b545fb68a117335b587595f9d90399db12

Contents?: true

Size: 1.97 KB

Versions: 4

Compression:

Stored size: 1.97 KB

Contents

require 'rubygems'
require 'cli/command'

module Factor
  module CLI
    class Server < Command
      desc "start", "start the server"
      method_option :tags, :alias=>"-t", :type=>:hash, :desc=>"Optional tags to identify from workflow"
      method_option :channels, :type=>:array, :desc=>"Optional channel ruby file list for development"
      def start
        engine = Factor::Runtime::Engine.new(get_config[:email],get_config[:token])
        
        options.tags.each {|tag,value| engine.tag(tag,value)} if options.tags?
   
        # load channels from server
        puts "loading channels from server"
        engine = @client.load_channels(engine) do |message|
          puts "  #{message}"
        end
        
        # load channels from files
        if options.channels?
          options.channels.each do |file|
            full_file=File.expand_path(file)
            puts "  loading '#{full_file}'"
            engine.load_channel(full_file)
            puts "  loaded '#{full_file}'"
          end
        end
        
        puts "loading channels complete"
      
      
        # load workflows from server
        puts "loading workflows from server"
        engine = @client.load_workflows(engine) do |message|
          puts "  #{message}"
        end
        puts "loading workflows complete"
    
        puts "loading credentials from server"
        engine = @client.load_credentials(engine) do |message|
          puts "  #{message}"
        end
        puts "loading credentials complete"
    
        puts "starting the server..."
        engine.start
    
      end
  
      desc "list", "list all the running servers"
      def list
        puts "listing all servers"
      end
  
      desc "logs", "listen to incoming logs"
      def logs
        engine = Factor::Runtime::Engine.new(get_config[:email],get_config[:token])
        puts "Listening..."
        engine.logs do |message|
          puts "[#{message.route}] #{message.body}"
        end
      end
  
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
factor-0.0.91 lib/cli/server.rb
factor-0.0.90 lib/cli/server.rb
factor-0.0.89 lib/cli/server.rb
factor-0.0.88 lib/cli/server.rb