luban-rack 0.1.1 → 0.1.2

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: 75dff673fdfb8b910f2c8a5fc1c9a831cd5c313f
4
- data.tar.gz: 6e16e73badf9284fa25dbc3957382089f99ff2c3
3
+ metadata.gz: cbb9ea87d6f534b68912727570e3c6233ef32685
4
+ data.tar.gz: de08144a0493b050f6d979f62c5ac789f6dfbf2e
5
5
  SHA512:
6
- metadata.gz: 29bd4d9a3c43e62e1b9c1887eddffe4328039788f8c00e9197c241d455b64690cda4cee8bf2b2650a48d62d320bf715242d4f46026c4346998b7ef4e4fa813d6
7
- data.tar.gz: c582a1f63b6871c4209e2b2836e792f1f16e905fa21730b194b4d0e7ec6f9c2f17114369ea33b9252bc0a24619579a5888508abd63979772f70fd99091c3f768
6
+ metadata.gz: bd634449efb923be8f666a6da47ca5a7db3d8505de69e26de267852536217f906990b82367534b8bc608f2290417e8d3cddaa22da4800f6d0617f1a1fd653b41
7
+ data.tar.gz: 454d1316ad6cbec1cac6eef112a1dd2099198c69abadca773b128923a59cc220baaf28e2a1e8e878974e9d857ff47ea356fb42d83e08c3a3bd2895f54aef3ada
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Change log
2
2
 
3
+ ## Version 0.1.2 (Jul 14, 2016)
4
+
5
+ New features:
6
+ * Supported generation of Nginx proxy configuration
7
+
8
+ * Bug fixes:
9
+ * Fixed issues to correctly set default web server options for Configurator and Controller
10
+ * Corrected issues when composing socket file path for cluster
11
+ * Changed the starting port for cluster to avoid conflicting to the actual port the web app uses
12
+
3
13
  ## Version 0.1.1 (Jul 11, 2016)
4
14
 
5
15
  New features:
@@ -5,10 +5,14 @@ module Luban
5
5
  using Luban::CLI::CoreRefinements
6
6
 
7
7
  module Parameters
8
- extend Luban::Deployment::Parameters::Base
8
+ extend Luban::Deployment::Parameters::Base
9
9
 
10
+ DefaultPort = 3000
11
+ DefaultVirtualHost = 'localhost'
10
12
  DefaultWebServer = :thin
11
13
 
14
+ parameter :port
15
+ parameter :virtual_host
12
16
  parameter :web_server
13
17
 
14
18
  def power_by(server, **opts)
@@ -18,6 +22,8 @@ module Luban
18
22
  protected
19
23
 
20
24
  def set_default_rack_parameters
25
+ set_default :port, DefaultPort
26
+ set_default :virtual_host, DefaultVirtualHost
21
27
  set_default :web_server, name: DefaultWebServer, opts: {}
22
28
  end
23
29
  end
@@ -9,6 +9,11 @@ module Luban
9
9
 
10
10
  protected
11
11
 
12
+ def init
13
+ super
14
+ set_default_web_server_options unless task.opts.release.nil?
15
+ end
16
+
12
17
  def web_server_module(path)
13
18
  @web_server_module ||= super.const_get('Common')
14
19
  end
@@ -33,6 +33,11 @@ module Luban
33
33
 
34
34
  protected
35
35
 
36
+ def init
37
+ super
38
+ set_default_web_server_options
39
+ end
40
+
36
41
  def restart_process!
37
42
  capture("#{restart_command} 2>&1")
38
43
  end
@@ -43,12 +43,21 @@ module Luban
43
43
  @sockets_path ||= shared_path.join('sockets')
44
44
  end
45
45
 
46
- def socket_file_path
47
- @socket_file_path ||= sockets_path.join(socket_file_name)
46
+ def socket_file_path(n = nil)
47
+ if n.nil?
48
+ @socket_file_path ||= sockets_path.join(socket_file_name)
49
+ else
50
+ sockets_path.join(socket_file_name(n))
51
+ end
48
52
  end
49
53
 
50
- def socket_file_name
51
- @socket_file_name ||= "#{web_server[:name]}.sock"
54
+ def socket_file_name(n = nil)
55
+ if n.nil?
56
+ @socket_file_name ||= "#{web_server[:name]}.sock"
57
+ else
58
+ "#{web_server[:name]}.#{n}.sock"
59
+ end
60
+
52
61
  end
53
62
 
54
63
  def ruby_bin_path
@@ -0,0 +1,45 @@
1
+ # Nginx reverse proxy configuration for Thin
2
+
3
+ <% opts = web_server[:opts] -%>
4
+ upstream <%= service_entry %> {
5
+ # fail_timeout=0 means we always retry an upstream even if it failed
6
+ # to return a good HTTP response
7
+
8
+ <%- if opts[:port] -%>
9
+ <%- opts[:servers].times do |n| -%>
10
+ server <%= opts[:address] %>:<%= opts[:port] + n %> fail_timeout=0;
11
+ <%- end -%>
12
+ <%- end -%>
13
+ <%- if opts[:socket] -%>
14
+ <%- opts[:servers].times do |n| -%>
15
+ server unix:<%= socket_file_path(n) %> fail_timeout=0;
16
+ <%- end -%>
17
+ <%- end -%>
18
+ }
19
+
20
+ server {
21
+ listen <%= port %>;
22
+ server_name <%= virtual_host %>;
23
+
24
+ # ~2 seconds is often enough for most cases to parse HTML/CSS and
25
+ # retrieve needed images/icons/frames, connections are cheap in
26
+ # nginx so increasing this is generally safe...
27
+ keepalive_timeout 5;
28
+
29
+ # path for static files
30
+ root <%= current_app_path %>/public;
31
+
32
+ location ~ ^/assets/ {
33
+ gzip_static on; # to serve pre-gizpped version
34
+ expires 1y;
35
+ add_header Cache-Control public;
36
+ add_header ETag "";
37
+ break;
38
+ }
39
+
40
+ try_files $uri/index.html $uri.html $uri @app;
41
+
42
+ location @app {
43
+ proxy_pass http://<%= service_entry %>;
44
+ }
45
+ }
@@ -10,7 +10,7 @@ check process <%= service_entry %>.<%= web_server[:name] %>.<%= n %>
10
10
  stop program = "/bin/bash -c '<%= stop_command %> -o <%=n %>'"
11
11
  if totalmem is greater than 150.0 MB for 40 cycles then alert
12
12
  <%- if opts[:port] -%>
13
- if failed port <%= opts[:port].to_i + n %> for 4 times within 8 cycles then restart
13
+ if failed port <%= opts[:port] + n %> for 4 times within 8 cycles then restart
14
14
  <%- end -%>
15
15
  <%- if opts[:socket] -%>
16
16
  if failed unixsocket <%= socket_file_path(n) %> for 4 times within 8 cycles then restart
@@ -2,7 +2,7 @@ module Luban
2
2
  module Deployment
3
3
  module Applications
4
4
  class Rack
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  end
8
8
  end
@@ -18,7 +18,6 @@ module Luban
18
18
  def load_web_server
19
19
  require web_server_require_path
20
20
  singleton_class.send(:prepend, web_server_module(web_server_require_path))
21
- set_default_web_server_options
22
21
  rescue LoadError => e
23
22
  abort "Aborted! Failed to load web server #{web_server[:name].inspect}."
24
23
  end
@@ -9,7 +9,7 @@ module Luban
9
9
  @default_web_server_options ||= {
10
10
  # Server options
11
11
  address: "0.0.0.0",
12
- port: 3000,
12
+ port: port + 1,
13
13
  socket: socket_file_path.to_s,
14
14
  chdir: release_path.to_s,
15
15
  # Adapter options
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luban-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rubyist Chi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: luban
@@ -88,6 +88,7 @@ files:
88
88
  - lib/luban/deployment/applications/rack/configurator.rb
89
89
  - lib/luban/deployment/applications/rack/controller.rb
90
90
  - lib/luban/deployment/applications/rack/paths.rb
91
+ - lib/luban/deployment/applications/rack/templates/thin/nginx.http.proxy.conf.erb
91
92
  - lib/luban/deployment/applications/rack/templates/thin/thin.logrotate.erb
92
93
  - lib/luban/deployment/applications/rack/templates/thin/thin.monitrc.erb
93
94
  - lib/luban/deployment/applications/rack/templates/thin/thin.yml.erb