luban-monit 0.1.3 → 0.1.4

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: e53c03f03a97b63aa892705ef24b63f394da0420
4
- data.tar.gz: 6cbd637fd3477ba06eb0dccef3060a2e07980732
3
+ metadata.gz: 165a9d12131d359b2353e195b3aac485e0859c78
4
+ data.tar.gz: 005aaa6659ef4df89a21170ce92a0b11c46ce09f
5
5
  SHA512:
6
- metadata.gz: 1d48c656f729349f9787c7472b7e9c4038cab312324186d86c58c673c9cda461127e1f29c17fd1106951ab3e1dbcb9c23a8faa7c9697ae8231a6844d4777380f
7
- data.tar.gz: 6857f8eaccfe97ad6aa17bb99ec8678067d7a4d030dd027ac6692f64860266ccace9cdc5102252d3bf22ac9785d465d99bd49d54b3c0415986cc740135dc10d7
6
+ metadata.gz: e0f245fce78458ae4b3b515cd62d5af395356ba9b7c8386fe1976222a6926154d9511a1be56aa9ee7aa2a43f46fe5cd2f002421a836e6bf1c6e1d3b9ba47f500
7
+ data.tar.gz: 15976741e6214481642ee755eeeaf960a5aad791b8fb8547e4cba0c6a8b1ef616db1865434c5c21e41f1cdc97efa3086466bd91428da31b9f27712f1eeaaeb7a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change log
2
2
 
3
+ ## Version 0.1.4 (Jun 07, 2016)
4
+
5
+ Minor enhancements:
6
+ * Added two new subcommands:
7
+ * #config_test: Syntax check on config file
8
+ * #reload: reload monit deamon process
9
+ * Use "etc" as the default search path for control file
10
+ * Minor code refactoring
11
+
3
12
  ## Version 0.1.3 (May 13, 2016)
4
13
 
5
14
  Minor enhancements:
@@ -12,6 +12,9 @@ module Luban
12
12
  @default_templates_path ||= Pathname.new(File.join(File.dirname(__FILE__), 'templates')).realpath
13
13
  end
14
14
 
15
+ service_action :config_test, dispatch_to: :controller
16
+ service_action :reload_process, dispatch_to: :controller
17
+
15
18
  protected
16
19
 
17
20
  def setup_install_tasks
@@ -21,8 +24,16 @@ module Luban
21
24
 
22
25
  def setup_control_tasks
23
26
  super
24
- undef_task :monitor
25
- undef_task :unmonitor
27
+
28
+ task :config_test do
29
+ desc "Syntax check on control file"
30
+ action! :config_test
31
+ end
32
+
33
+ task :reload do
34
+ desc "Reload process"
35
+ action! :reload_process
36
+ end
26
37
  end
27
38
  end
28
39
  end
@@ -3,29 +3,25 @@ module Luban
3
3
  module Packages
4
4
  class Monit
5
5
  class Configurator < Luban::Deployment::Service::Configurator
6
- module Paths
7
- def control_file_name
8
- @control_file_name ||= 'monitrc'
9
- end
10
-
11
- def state_file_path
12
- @state_file_path ||= pids_path.join(state_file_name)
13
- end
6
+ def control_file_name
7
+ @control_file_name ||= 'monitrc'
8
+ end
14
9
 
15
- def state_file_name
16
- @state_file_name ||= "#{service_name}.state"
17
- end
10
+ def state_file_path
11
+ @state_file_path ||= pids_path.join(state_file_name)
12
+ end
18
13
 
19
- def id_file_path
20
- @id_file_path ||= pids_path.join(id_file_name)
21
- end
14
+ def state_file_name
15
+ @state_file_name ||= "#{service_name}.state"
16
+ end
22
17
 
23
- def id_file_name
24
- @id_file_name ||= "#{service_name}.id"
25
- end
18
+ def id_file_path
19
+ @id_file_path ||= pids_path.join(id_file_name)
26
20
  end
27
21
 
28
- include Paths
22
+ def id_file_name
23
+ @id_file_name ||= "#{service_name}.id"
24
+ end
29
25
 
30
26
  def services_path
31
27
  @services_path ||= env_path.join("#{stage}.*").join("*").join("shared").
@@ -3,27 +3,35 @@ module Luban
3
3
  module Packages
4
4
  class Monit
5
5
  class Controller < Luban::Deployment::Service::Controller
6
- include Configurator::Paths
7
-
8
6
  default_executable 'monit'
9
7
 
10
8
  def monit_command
11
- @monit_command ||= "#{monit_executable} -c #{control_file_path}"
9
+ @monit_command ||= "#{monit_executable}"
12
10
  end
11
+ alias_method :process_pattern, :monit_command
13
12
 
14
13
  def process_stopped?
15
- check_process! =~ /the monit daemon is not running$/
14
+ super and check_process! =~ /the monit daemon is not running$/
16
15
  end
17
16
 
18
17
  def process_started?
19
- check_process! =~ /^The Monit daemon #{package_major_version} uptime:/
18
+ super and check_process! =~ /^The Monit daemon #{package_major_version} uptime:/
19
+ end
20
+
21
+ def config_test
22
+ update_result config_test!
20
23
  end
21
24
 
22
- undef_method :monitor_process
23
- undef_method :unmonitor_process
25
+ def reload_process
26
+ update_result reload_process!
27
+ end
24
28
 
25
29
  protected
26
30
 
31
+ def config_test!
32
+ capture("#{monit_command} -t 2>&1")
33
+ end
34
+
27
35
  def start_process!
28
36
  capture("#{monit_command} 2>&1")
29
37
  end
@@ -35,6 +43,10 @@ module Luban
35
43
  def check_process!
36
44
  capture("#{monit_command} status 2>&1")
37
45
  end
46
+
47
+ def reload_process!
48
+ capture("#{monit_command} reload 2>&1")
49
+ end
38
50
  end
39
51
  end
40
52
  end
@@ -3,8 +3,6 @@ module Luban
3
3
  module Packages
4
4
  class Monit
5
5
  class Installer < Luban::Deployment::Service::Installer
6
- include Configurator::Paths
7
-
8
6
  default_executable 'monit'
9
7
 
10
8
  def source_repo
@@ -22,7 +20,16 @@ module Luban
22
20
  end
23
21
 
24
22
  def with_openssl_dir(dir)
25
- @configure_opts << "--with-ssl-static="#{dir}"
23
+ @configure_opts << "--with-ssl-static=#{dir}"
24
+ end
25
+
26
+ protected
27
+
28
+ def install!
29
+ super
30
+ # Symlink 'etc' to the profile path
31
+ # 'etc' is the default search path for control file
32
+ ln(profile_path, install_path.join('etc'))
26
33
  end
27
34
  end
28
35
  end
@@ -1,8 +1,8 @@
1
1
  # Monit logrotate configuration
2
2
 
3
- # Environment: <%= env_name = "#{stage}.#{project}/#{application}" %>
3
+ # Environment: <%= env_name %>
4
4
  # Revision: <%= revision %>
5
- # Created at <%= Time.now().strftime("%d/%m/%Y %H:%M:%S") %>
5
+ # Created at <%= now %>
6
6
 
7
7
  <%= log_file_path %> {
8
8
  daily
@@ -1,8 +1,8 @@
1
1
  # Monit control file
2
2
 
3
- # Environment: <%= env_name = "#{stage}.#{project}/#{application}" %>
3
+ # Environment: <%= env_name %>
4
4
  # Revision: <%= revision %>
5
- # Created at <%= Time.now().strftime("%d/%m/%Y %H:%M:%S") %>
5
+ # Created at <%= now %>
6
6
 
7
7
  set daemon 15 # Poll cycle length in seconds
8
8
 
@@ -2,7 +2,7 @@ module Luban
2
2
  module Deployment
3
3
  module Packages
4
4
  class Monit
5
- VERSION = '0.1.3'
5
+ VERSION = '0.1.4'
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luban-monit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
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-05-13 00:00:00.000000000 Z
11
+ date: 2016-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: luban