spurious-server 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e1e67665b759bc849148c943f8222957baf35df
4
- data.tar.gz: 1cef1301ecc27616d24386f5850debd455df03f0
3
+ metadata.gz: 1cfbf2cf494c6d343c7d03ffd283fc256f27edc2
4
+ data.tar.gz: 4b1c7df840777138786a87e9ee3b1c850b165691
5
5
  SHA512:
6
- metadata.gz: e65dbf04c5d492a34601eeeffe35500460b13b6dc31ffd88282b54dad69f484d9e74f655fb2d6bbd1cf66ebee431117db8b8e21b2bd39e2c9e30f8025f500992
7
- data.tar.gz: 71cc517136fe037e00525518229657a2fb889baaea2b386c404b4be1781544c64401390fcec1771907c99f184179a54ca45d419c05304857f0914056afb0b357
6
+ metadata.gz: 20a74b83f99bb52d367892bd39a8436b9b1be5c4b5a70944a4e6eeeb90b1288c7cf4ecdc0875ff715affc23bf2d7920e0ce4f8ec4f065c4ac0762edcd4fa623c
7
+ data.tar.gz: dcdcd072cb3705af6408c2b80ad4cb24730d45ade571855fc830b8c4efece1280115dbd43e0249be7267c5f993ec910305f945cf6e2581269897679b0c7a27b7
data/bin/spurious-server CHANGED
@@ -3,18 +3,16 @@
3
3
  $: << File.join(File.dirname(__FILE__), '..', 'lib')
4
4
 
5
5
  require 'spurious/server'
6
- require "spurious/server/version"
6
+ require 'spurious/server/version'
7
7
  require 'daemons'
8
- require "eventmachine"
8
+ require 'eventmachine'
9
+ require 'spurious/server/options'
9
10
 
10
- docker_host = ENV.fetch('DOCKER_HOST', 'tcp://0.0.0.0:2375')
11
- ip = ENV.fetch('SPURIOUS_SERVER_IP', '0.0.0.0')
12
- port = ENV.fetch('SPURIOUS_SERVER_PORT', 4590)
13
- Docker.url = docker_host
11
+ options = Spurious::Server::Options.new(ENV)
14
12
 
15
- Excon.defaults[:write_timeout] = 20000
16
- Excon.defaults[:read_timeout] = 20000
13
+ Excon.defaults[:write_timeout] = options.write_timeout
14
+ Excon.defaults[:read_timeout] = options.read_timeout
17
15
 
18
16
  Daemons.run_proc('Spurious Server', :dir => '/tmp', :log_output => true) do
19
- EventMachine.run Spurious::Server.handle(ip, port, docker_host)
17
+ EventMachine.run Spurious::Server.handle(options)
20
18
  end
@@ -5,9 +5,14 @@ require "spurious/server/app"
5
5
  module Spurious
6
6
  module Server
7
7
 
8
- def self.handle(ip, port, docker_host)
8
+ def self.handle(options)
9
9
  Proc.new do
10
- EventMachine.start_server ip, port, Spurious::Server::App, docker_host
10
+ EventMachine.start_server(
11
+ options.server_ip,
12
+ options.server_port,
13
+ Spurious::Server::App,
14
+ options
15
+ )
11
16
  end
12
17
  end
13
18
 
@@ -7,13 +7,10 @@ require "json"
7
7
  module Spurious
8
8
  module Server
9
9
  class App < EventMachine::Connection
10
+ attr_accessor :options
10
11
 
11
- def initialize(docker_host)
12
- @docker_host = docker_host
13
- end
14
-
15
- def docker_host_ip
16
- @docker_host[/\/\/([0-9\.]+):/,1]
12
+ def initialize(options)
13
+ @options = options
17
14
  end
18
15
 
19
16
  def receive_data data
@@ -27,7 +24,7 @@ module Spurious
27
24
  protected
28
25
 
29
26
  def state(type)
30
- Spurious::Server::State::Factory.create(type, self, config, docker_host_ip)
27
+ Spurious::Server::State::Factory.create(type, self, config, options)
31
28
  end
32
29
 
33
30
  def config
@@ -0,0 +1,18 @@
1
+ module Spurious
2
+ module Server
3
+ class Options
4
+ attr_reader :docker_full_path, :docker_host, :docker_port, :docker_api, :server_port, :server_ip, :write_timeout, :read_timeout
5
+
6
+ def initialize(env)
7
+ @docker_host = env['DOCKER_HOST'].nil? ? 'localhost' : env['DOCKER_HOST'][/\/\/([0-9a-z\.]+):/,1]
8
+ @docker_port = env['DOCKER_HOST'].nil? ? nil : env['DOCKER_HOST'][/:([0-9]+)/,1]
9
+ @docker_api = !env['DOCKER_HOST'].nil?
10
+ @server_port = env.fetch('SPURIOUS_SERVER_PORT', 4590)
11
+ @server_ip = env.fetch('SPURIOUS_SERVER_IP', '0.0.0.0')
12
+ @write_timeout = env.fetch('EXCON_WRITE_TIMEOUT', 30000)
13
+ @read_timeout = env.fetch('EXCON_READ_TIMEOUT', 30000)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -11,16 +11,16 @@ module Spurious
11
11
  module State
12
12
  module Factory
13
13
 
14
- def self.create(type, connection, config, docker_host_ip)
14
+ def self.create(type, connection, config, options)
15
15
  case type.to_sym
16
16
  when :init
17
17
  Init.new(connection, config)
18
18
  when :start
19
- Start.new(connection, config, docker_host_ip)
19
+ Start.new(connection, config, options.docker_host)
20
20
  when :stop
21
21
  Stop.new(connection, config)
22
22
  when :ports
23
- Ports.new(connection, config, docker_host_ip)
23
+ Ports.new(connection, config, options.docker_host)
24
24
  when :delete
25
25
  Delete.new(connection, config)
26
26
  when :update
@@ -1,5 +1,5 @@
1
1
  module Spurious
2
2
  module Server
3
- VERSION = "0.2.2"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spurious-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-14 00:00:00.000000000 Z
11
+ date: 2014-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,6 +127,7 @@ files:
127
127
  - lib/spurious/server.rb
128
128
  - lib/spurious/server/app.rb
129
129
  - lib/spurious/server/config.rb
130
+ - lib/spurious/server/options.rb
130
131
  - lib/spurious/server/state/base.rb
131
132
  - lib/spurious/server/state/delete.rb
132
133
  - lib/spurious/server/state/error.rb
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  version: '0'
168
169
  requirements: []
169
170
  rubyforge_project:
170
- rubygems_version: 2.2.2
171
+ rubygems_version: 2.0.3
171
172
  signing_key:
172
173
  specification_version: 4
173
174
  summary: The server component that the spurious cli client connects to