luban-nginx 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d56320d742c77de9f7c3f5940849211f958500de
4
- data.tar.gz: 74ffd91524d3a5b4f8789d12bf16abbcabc43166
3
+ metadata.gz: 6eebed13089ab8504ba7fad7fe505ee0e0a07dad
4
+ data.tar.gz: 333d8d4b66ec26f7428fbe5b426236ce2d1ce6d9
5
5
  SHA512:
6
- metadata.gz: a446438849629953e9d6cbc3f31fe566e28fe1d48084dcdb03fbf4ef9293b618729d9d97bfbe9430492a159a5d327e611aef3f0753ba612a6d6abbb4546acaff
7
- data.tar.gz: d8f32737378e85caf57457340280bf81825660670e50002f7730bc3871f3a5a571f4f25eb292cbdb25c59aa1c18c9794e36c3267f5119fe56af331c63a03ce50
6
+ metadata.gz: 5c1424e41aa0650d9edf1eac6cdeb215655eeb2c550dc95e49988b336396687bb1f48b7cc000b7e96c2108800b662ff9582f7d664591c95fbc262fbfc673dc33
7
+ data.tar.gz: d03f27e9781ffe8cda82c8916e21d7eaff94c32744acc40a1e90133098d2a24f4f9657b4aa020caa331d0639af35eec8bb0a77a9a116b547b4c735cb89986d60
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change log
2
2
 
3
+ ## Version 0.1.1 (Jun 16, 2016)
4
+
5
+ Minor enhancements:
6
+ * Refatored commands definitions for better reusability among service workers
7
+ * Simplified erb templates by removing header information like revision, environment, etc.
8
+ * Header info is generated by Luban (with a generic header template which could be customized if needed)
9
+
3
10
  ## Version 0.1.0 (May 11, 2016)
4
11
 
5
12
  New features:
@@ -1,7 +1,7 @@
1
1
  require 'luban'
2
2
  require_relative 'nginx/base'
3
- require_relative 'nginx/configurator'
4
3
  require_relative 'nginx/controller'
4
+ require_relative 'nginx/configurator'
5
5
  require_relative 'nginx/installer'
6
6
  require_relative 'nginx/version'
7
7
 
@@ -3,13 +3,7 @@ module Luban
3
3
  module Packages
4
4
  class Nginx
5
5
  class Configurator < Luban::Deployment::Service::Configurator
6
- module Paths
7
- def bin_path
8
- @bin_path ||= install_path.join('sbin')
9
- end
10
- end
11
-
12
- include Paths
6
+ include Controller::Commands
13
7
 
14
8
  def error_log_file_path
15
9
  @error_log_file_path ||= log_path.join(error_log_file_name)
@@ -31,9 +25,7 @@ module Luban
31
25
  if file?(stage_profile_path.join(mime_types_file_name))
32
26
  profile_path.join(mime_types_file_name)
33
27
  else
34
- #Pathname.new('conf').join(mime_types_file_name)
35
28
  current_path.join('conf').join(mime_types_file_name)
36
- #install_path.join('conf').join(mime_types_file_name)
37
29
  end
38
30
  end
39
31
 
@@ -3,17 +3,33 @@ module Luban
3
3
  module Packages
4
4
  class Nginx
5
5
  class Controller < Luban::Deployment::Service::Controller
6
- include Configurator::Paths
6
+ module Commands
7
+ def self.included(base)
8
+ base.define_executable 'nginx'
9
+ end
10
+
11
+ def bin_path
12
+ @bin_path ||= install_path.join('sbin')
13
+ end
14
+
15
+ def nginx_command
16
+ @nginx_command ||= "#{nginx_executable} -c #{control_file_path}"
17
+ end
7
18
 
8
- default_executable 'nginx'
19
+ alias_method :process_pattern, :nginx_command
20
+ alias_method :start_command, :nginx_command
9
21
 
10
- def nginx_command
11
- @nginx_command ||= "#{nginx_executable} -c #{control_file_path}"
22
+ def stop_command
23
+ @stop_command ||= "#{nginx_command} -s stop"
24
+ end
12
25
  end
13
- alias_method :process_pattern, :nginx_command
14
26
 
15
- def config_test
16
- update_result config_test!
27
+ include Commands
28
+
29
+ %w(config_test reload_process reopen_logs).each do |method|
30
+ define_method(method) do
31
+ update_result send("#{method}!")
32
+ end
17
33
  end
18
34
 
19
35
  def quit_process
@@ -22,9 +38,9 @@ module Luban
22
38
  return
23
39
  end
24
40
 
41
+ unmonitor_process
25
42
  output = quit_process!
26
43
  if check_until { process_stopped? }
27
- unmonitor_process
28
44
  update_result "Gracefully stop #{package_full_name}: [OK] #{output}"
29
45
  else
30
46
  remove_orphaned_pid_file
@@ -33,34 +49,16 @@ module Luban
33
49
  end
34
50
  end
35
51
 
36
- def before_quit; unmonitor_process; end
37
-
38
- def reload_process
39
- update_result reload_process!
40
- end
41
-
42
- def reopen_logs
43
- update_result reopen_logs!
44
- end
45
-
46
52
  protected
47
53
 
48
54
  def config_test!
49
55
  capture("#{nginx_command} -t 2>&1")
50
56
  end
51
57
 
52
- def start_process!
53
- capture("#{nginx_command} 2>&1")
54
- end
55
-
56
58
  def quit_process!
57
59
  capture("#{nginx_command} -s quit 2>&1")
58
60
  end
59
61
 
60
- def stop_process!
61
- capture("#{nginx_command} -s stop 2>&1")
62
- end
63
-
64
62
  def reload_process!
65
63
  capture("#{nginx_command} -s reload 2>&1")
66
64
  end
@@ -72,4 +70,4 @@ module Luban
72
70
  end
73
71
  end
74
72
  end
75
- end
73
+ end
@@ -3,9 +3,7 @@ module Luban
3
3
  module Packages
4
4
  class Nginx
5
5
  class Installer < Luban::Deployment::Service::Installer
6
- include Configurator::Paths
7
-
8
- default_executable 'nginx'
6
+ include Controller::Commands
9
7
 
10
8
  def source_repo
11
9
  @source_repo ||= "http://nginx.org"
@@ -49,4 +47,4 @@ module Luban
49
47
  end
50
48
  end
51
49
  end
52
- end
50
+ end
@@ -1,9 +1,5 @@
1
1
  # Nginx master configuration file
2
2
 
3
- # Environment: <%= env_name %>
4
- # Revision: <%= revision %>
5
- # Created at <%= now %>
6
-
7
3
  pid <%= pid_file_path %>;
8
4
  error_log <%= error_log_file_path %> info;
9
5
 
@@ -40,4 +40,4 @@ proxy_redirect off;
40
40
  # -------------------------------------
41
41
  log_format main '$remote_addr - $remote_user [$time_local] $status '
42
42
  '"$request" $body_bytes_sent "$http_referer" '
43
- '"$http_user_agent" "$http_x_forwarded_for" "$request_time"';
43
+ '"$http_user_agent" "$http_x_forwarded_for" "$request_time"';
@@ -1,9 +1,5 @@
1
1
  # Nginx reverse proxy configuration
2
2
 
3
- # Environment: <%= env_name %>
4
- # Revision: <%= revision %>
5
- # Created at <%= now %>
6
-
7
3
  upstream <%= serivce_entry %> {
8
4
  # fail_timeout=0 means we always retry an upstream even if it failed
9
5
  # to return a good HTTP response (in case the Puma master nukes a
@@ -1,9 +1,5 @@
1
1
  # Nginx logrotate configuration
2
2
 
3
- # Environment: <%= env_name %>
4
- # Revision: <%= revision %>
5
- # Created at <%= now %>
6
-
7
3
  <%= log_path.join('*.log') %> {
8
4
  daily
9
5
  missingok
@@ -1,15 +1,10 @@
1
1
  # Monit control file for Nginx
2
2
 
3
- # Environment: <%= env_name %>
4
- # Revision: <%= revision %>
5
- # Created at <%= now %>
6
-
7
- <% nginx_command = "#{bin_path.join('nginx')} -c #{control_file_path}" %>
8
3
  check process <%= service_entry %>
9
4
  with pidfile <%= pid_file_path %>
10
- start program = "/bin/bash -c 'sleep 1; <%= nginx_command %>'"
11
- stop program = "/bin/bash -c '<%= "#{nginx_command} -s stop" %>'"
5
+ start program = "/bin/bash -c 'sleep 1; <%= start_command %>'"
6
+ stop program = "/bin/bash -c '<%= stop_command %>'"
12
7
  if totalmem is greater than 10.0 MB for 40 cycles then restart
13
- if failed port 8080 for 3 times within 6 cycles then restart
8
+ if failed port 8080 for 4 times within 8 cycles then restart
14
9
  if cpu is greater than 80% for 20 cycles then alert
15
10
  if loadavg(5min) greater than 10 for 40 cycles then restart
@@ -2,7 +2,7 @@ module Luban
2
2
  module Deployment
3
3
  module Packages
4
4
  class Nginx
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
8
8
  end
@@ -6,7 +6,7 @@ module Luban
6
6
  class Pcre < Luban::Deployment::Package::Base
7
7
  class Installer < Luban::Deployment::Package::Installer
8
8
  def pcre_executable
9
- @default_executable ||= bin_path.join('pcre-config')
9
+ @pcre_executable ||= bin_path.join('pcre-config')
10
10
  end
11
11
 
12
12
  def source_repo
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luban-nginx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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-06-07 00:00:00.000000000 Z
11
+ date: 2016-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: luban