ringleader 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -63,7 +63,7 @@ Yep. Hook it up with [fluid](http://fluidapp.com) and put it in the menu bar. By
63
63
  default it runs at [http://localhost:42000](http://localhost:42000).
64
64
 
65
65
 
66
- ![screenshot of ringleader control panel](/aniero/ringleader/raw/master/screenshot.png)
66
+ ![screenshot of ringleader control panel](screenshot.png)
67
67
 
68
68
  ## Installation
69
69
 
@@ -89,14 +89,16 @@ main_app:
89
89
 
90
90
  # Optional settings
91
91
  host: 127.0.0.1 # The host ringleader should listen on
92
- idle_timeout: 6000 # Idle timeout in seconds
92
+ idle_timeout: 6000 # Idle timeout in seconds, 0 for infinite
93
93
  startup_timeout: 180 # Application startup timeout
94
94
  disabled: true # Set the app to be disabled when ringleader starts
95
95
  env: # Override or set environment variables inherited
96
96
  FOO: hello # from the current environment. Use nil to unset a
97
97
  BAR: nil # var.
98
- kill_with: TERM # Signal to use to kill the process tree with. Use
99
- # KILL if the default (TERM) is leaving zombies.
98
+ kill_with: INT # Signal to use to kill the process tree with. Use
99
+ # TERM or KILL if the default is leaving zombies.
100
+ run_on_load: false # Set this to true to start an app when ringleader
101
+ # loads.
100
102
 
101
103
  # If you have an application managed by rvm, this setting automatically adds
102
104
  # the rvm-specific shell setup before executing the given command. This
@@ -13,8 +13,7 @@
13
13
  padding-top: 60px; /* 60px to make the container go all the way to the bottom of the top bar */
14
14
  }
15
15
  .app {
16
- padding-bottom: 5px;
17
- margin-bottom: 5px;
16
+ padding: 5px 0;
18
17
  border-bottom: 1px solid #CCC;
19
18
  clear: both;
20
19
  }
@@ -35,6 +34,9 @@
35
34
  .app .buttons {
36
35
  text-align: right;
37
36
  }
37
+ .app:nth-child(even) {
38
+ background-color: #eeeeee;
39
+ }
38
40
  .loading {
39
41
  padding-top: 5px;
40
42
  height: 23px; /* 23 + 5 = 28, height of buttons */
@@ -0,0 +1,51 @@
1
+ ---
2
+ one:
3
+ dir: "./dev_scripts"
4
+ command: "ncat -k -l 10001"
5
+ server_port: 10001
6
+ app_port: 20001
7
+ two:
8
+ dir: "./dev_scripts"
9
+ command: "ncat -k -l 10002"
10
+ server_port: 10002
11
+ app_port: 20002
12
+ three:
13
+ dir: "./dev_scripts"
14
+ command: "ncat -k -l 10003"
15
+ server_port: 10003
16
+ app_port: 20003
17
+ four:
18
+ dir: "./dev_scripts"
19
+ command: "ncat -k -l 10004"
20
+ server_port: 10004
21
+ app_port: 20004
22
+ five:
23
+ dir: "./dev_scripts"
24
+ command: "ncat -k -l 10005"
25
+ server_port: 10005
26
+ app_port: 20005
27
+ six:
28
+ dir: "./dev_scripts"
29
+ command: "ncat -k -l 10006"
30
+ server_port: 10006
31
+ app_port: 20006
32
+ seven:
33
+ dir: "./dev_scripts"
34
+ command: "ncat -k -l 10007"
35
+ server_port: 10007
36
+ app_port: 20007
37
+ eight:
38
+ dir: "./dev_scripts"
39
+ command: "ncat -k -l 10008"
40
+ server_port: 10008
41
+ app_port: 20008
42
+ nine:
43
+ dir: "./dev_scripts"
44
+ command: "ncat -k -l 10009"
45
+ server_port: 10009
46
+ app_port: 20009
47
+ ten:
48
+ dir: "./dev_scripts"
49
+ command: "ncat -k -l 10010"
50
+ server_port: 10010
51
+ app_port: 20010
@@ -12,6 +12,7 @@ module Ringleader
12
12
  @config = config
13
13
  @process = Process.new(config)
14
14
  enable! unless config.disabled
15
+ start if config.run_on_load
15
16
  end
16
17
 
17
18
  def name
@@ -67,7 +67,7 @@ APPLICATIONS
67
67
 
68
68
  Ringleader supports any application that runs in the foreground (not
69
69
  daemonized), and listens on a port. It expects applications to be well-behaved,
70
- that is, respond appropriately to SIGHUP for graceful shutdown.
70
+ that is, respond appropriately to SIGINT for graceful shutdown.
71
71
 
72
72
  When first starting an app, ringleader will wait for the application's port to
73
73
  open, at which point it will proxy the incoming connection through.
@@ -95,14 +95,16 @@ something like this:
95
95
 
96
96
  # Optional settings
97
97
  host: 127.0.0.1 # The host ringleader should listen on
98
- idle_timeout: 6000 # Idle timeout in seconds
98
+ idle_timeout: 6000 # Idle timeout in seconds, 0 for infinite
99
99
  startup_timeout: 180 # Application startup timeout
100
100
  disabled: true # Set the app to be disabled when ringleader starts
101
101
  env: # Override or set environment variables inherited
102
102
  FOO: hello # from the current environment. Use nil to unset a
103
103
  BAR: nil # var.
104
- kill_with: TERM # Signal to use to kill the process tree with. Use
105
- # KILL if the default (TERM) is leaving zombies.
104
+ kill_with: INT # Signal to use to kill the process tree with. Use
105
+ # TERM or KILL if the default is leaving zombies.
106
+ run_on_load: false # Set this to true to start an app when ringleader
107
+ # loads.
106
108
 
107
109
  # If you have an application managed by rvm, this setting automatically
108
110
  # adds the rvm-specific shell setup before executing the given command.
@@ -37,11 +37,16 @@ module Ringleader
37
37
  options["host"] ||= DEFAULT_HOST
38
38
  options["idle_timeout"] ||= DEFAULT_IDLE_TIMEOUT
39
39
  options["startup_timeout"] ||= DEFAULT_STARTUP_TIMEOUT
40
- options["kill_with"] ||= "TERM"
40
+ options["kill_with"] ||= "INT"
41
41
  options["env"] ||= {}
42
42
 
43
+ options["dir"] = File.expand_path options["dir"]
44
+ unless File.directory?(options["dir"])
45
+ raise ArgumentError, "#{options["dir"]} does not exist!"
46
+ end
47
+
43
48
  if command = options.delete("rvm")
44
- options["command"] = "source ~/.rvm/scripts/rvm && rvm --with-rubies rvmrc exec -- #{command}"
49
+ options["command"] = "source ~/.rvm/scripts/rvm && rvm in #{options["dir"]} do #{command}"
45
50
  elsif command = options.delete("rbenv")
46
51
  options["command"] = "rbenv exec #{command}"
47
52
  options["env"]["RBENV_VERSION"] = nil
@@ -51,8 +56,6 @@ module Ringleader
51
56
 
52
57
  validate name, options
53
58
 
54
- options["dir"] = File.expand_path options["dir"]
55
-
56
59
  [name, OpenStruct.new(options)]
57
60
  end
58
61
  end
@@ -61,7 +64,7 @@ module Ringleader
61
64
  def validate(name, options)
62
65
  REQUIRED_KEYS.each do |key|
63
66
  unless options.has_key?(key)
64
- raise "#{key} missing in #{name} config"
67
+ raise ArgumentError, "#{key} missing in #{name} config"
65
68
  end
66
69
  end
67
70
  end
@@ -1,3 +1,3 @@
1
1
  module Ringleader
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -0,0 +1,9 @@
1
+ ---
2
+ main_site:
3
+ dir: "~/does_not_exist"
4
+ command: "bundle exec foreman start"
5
+ host: "0.0.0.0"
6
+ server_port: 3000
7
+ app_port: 4000
8
+ idle_timeout: 1800
9
+
@@ -2,6 +2,16 @@ require "spec_helper"
2
2
 
3
3
  describe Ringleader::Config do
4
4
 
5
+ before :each do
6
+ File.stub(:directory?) do |arg|
7
+ if arg =~ %r(/apps/(main|admin|auth))
8
+ true
9
+ else
10
+ false
11
+ end
12
+ end
13
+ end
14
+
5
15
  context "when initialized with a config file" do
6
16
  subject { Ringleader::Config.new "spec/fixtures/config.yml" }
7
17
 
@@ -36,8 +46,8 @@ describe Ringleader::Config do
36
46
  expect(subject.apps["admin"].env).to have_key("OVERRIDE")
37
47
  end
38
48
 
39
- it "sets 'TERM' as the default kill signal" do
40
- expect(subject.apps["main_site"].kill_with).to eq("TERM")
49
+ it "sets 'INT' as the default kill signal" do
50
+ expect(subject.apps["main_site"].kill_with).to eq("INT")
41
51
  end
42
52
  end
43
53
  end
@@ -66,10 +76,18 @@ describe Ringleader::Config do
66
76
  end
67
77
  end
68
78
 
79
+ context "when the target directory doesn't exist" do
80
+ it "raises an exception" do
81
+ expect {
82
+ Ringleader::Config.new("spec/fixtures/invalid_app_dir.yml").apps
83
+ }.to raise_error(/does not exist/)
84
+ end
85
+ end
86
+
69
87
  context "with a config with an 'rvm' key instead of a 'command'" do
70
88
  it "replaces the rvm command with a command to use rvm" do
71
89
  config = Ringleader::Config.new "spec/fixtures/rvm.yml"
72
- expect(config.apps["rvm_app"].command).to match(/rvm.*rvmrc.*exec.*foreman/)
90
+ expect(config.apps["rvm_app"].command).to match(%r(rvm in \S+/apps/main do foreman start))
73
91
  end
74
92
  end
75
93
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ringleader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-03 00:00:00.000000000 Z
12
+ date: 2013-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: celluloid
@@ -191,6 +191,7 @@ files:
191
191
  - bin/ringleader
192
192
  - dev_scripts/Procfile
193
193
  - dev_scripts/echo_server.rb
194
+ - dev_scripts/many.yml
194
195
  - dev_scripts/signaling.rb
195
196
  - dev_scripts/signals.rb
196
197
  - dev_scripts/sleep_loop.rb
@@ -216,6 +217,7 @@ files:
216
217
  - screenshot.png
217
218
  - spec/fixtures/config.yml
218
219
  - spec/fixtures/invalid.yml
220
+ - spec/fixtures/invalid_app_dir.yml
219
221
  - spec/fixtures/no_app_port.yml
220
222
  - spec/fixtures/no_server_port.yml
221
223
  - spec/fixtures/rbenv.yml
@@ -240,15 +242,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
242
  - - ! '>='
241
243
  - !ruby/object:Gem::Version
242
244
  version: '0'
245
+ segments:
246
+ - 0
247
+ hash: -127958833266147469
243
248
  requirements: []
244
249
  rubyforge_project:
245
- rubygems_version: 1.8.24
250
+ rubygems_version: 1.8.23
246
251
  signing_key:
247
252
  specification_version: 3
248
253
  summary: Proxy TCP connections to an on-demand pool of configured applications
249
254
  test_files:
250
255
  - spec/fixtures/config.yml
251
256
  - spec/fixtures/invalid.yml
257
+ - spec/fixtures/invalid_app_dir.yml
252
258
  - spec/fixtures/no_app_port.yml
253
259
  - spec/fixtures/no_server_port.yml
254
260
  - spec/fixtures/rbenv.yml