capistrano-crono-monit 1.0
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 +7 -0
- data/.gitignore +19 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/capistrano-crono-monit.gemspec +21 -0
- data/lib/capistrano/crono/monit/version.rb +7 -0
- data/lib/capistrano/crono/monit.rb +1 -0
- data/lib/capistrano/crono/tasks/monit.rake +95 -0
- data/lib/capistrano/crono/templates/crono_monit.conf.erb +7 -0
- data/lib/capistrano-crono-monit.rb +0 -0
- data/lib/generators/capistrano/crono/monit/template_generator.rb +22 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 042bdd3d34965f9083803d2aa368463ff78d30df
|
4
|
+
data.tar.gz: 6b5281e86d4c280657666b58c14ddde9b0a2d50a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 19caacb44fe8e306426c5af879119a166bf1ffaae9efb36147b7bbeb65f7a207f686765f961e2078c9c2f7a2f4b9c6571a3f2f63da599705da8edf8137a1ffd5
|
7
|
+
data.tar.gz: 86ed9640897eec40c4b3fe5db176d4a953cff9d986380fdf774bc316bac14ea7be54de4cc26f842979685643aa480a6d7903df7653fefefe973ca27d95ec59b2
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Michał Mrozek
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Capistrano::Crono::Monit
|
2
|
+
|
3
|
+
Monit integration with capistrano-crono
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'capistrano-crono-monit', group: :development
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle install
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
```ruby
|
17
|
+
# Capfile
|
18
|
+
|
19
|
+
require 'capistrano/crono/monit'
|
20
|
+
```
|
21
|
+
|
22
|
+
## Dependencies
|
23
|
+
- capistrano-crono 0.1.2
|
24
|
+
|
25
|
+
## Customizing the monit crono templates
|
26
|
+
|
27
|
+
If you need change config for Monit, you can:
|
28
|
+
|
29
|
+
```
|
30
|
+
bundle exec rails generate capistrano:crono:monit:template
|
31
|
+
|
32
|
+
```
|
33
|
+
## Contributing
|
34
|
+
Feel free to contribute.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/crono/monit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'capistrano-crono-monit'
|
8
|
+
spec.version = Capistrano::Crono::Monit::VERSION
|
9
|
+
spec.authors = ['Michal Mrozek']
|
10
|
+
spec.email = ['michalmrozek@wp.pl']
|
11
|
+
spec.description = spec.summary = %q{Monit integration with capistrano-crono}
|
12
|
+
spec.homepage = 'https://github.com/Michsior14/capistrano-crono-monit'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.add_runtime_dependency 'capistrano', '~> 3.0', '>= 3.0.0'
|
16
|
+
spec.add_runtime_dependency 'capistrano-crono', '0.1.2'
|
17
|
+
|
18
|
+
spec.required_ruby_version = '>= 1.9.3'
|
19
|
+
spec.files = `git ls-files`.split($/)
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path('../tasks/monit.rake', __FILE__)
|
@@ -0,0 +1,95 @@
|
|
1
|
+
namespace :load do
|
2
|
+
task :defaults do
|
3
|
+
set :crono_monit_conf_dir, -> { "/etc/monit/conf.d/#{crono_monit_service_name}.conf" }
|
4
|
+
set :crono_monit_use_sudo, true
|
5
|
+
set :crono_monit_bin, '/usr/bin/monit'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
namespace :crono do
|
10
|
+
namespace :monit do
|
11
|
+
desc 'Config Crono monit-service'
|
12
|
+
task :config do
|
13
|
+
on roles(fetch(:crono_role)) do |role|
|
14
|
+
@role = role
|
15
|
+
template_crono 'crono_monit.conf', "#{fetch(:tmp_dir)}/crono_monit.conf"
|
16
|
+
sudo_if_needed "mv #{fetch(:tmp_dir)}/crono_monit.conf #{fetch(:crono_monit_conf_dir)}"
|
17
|
+
sudo_if_needed "#{fetch(:crono_monit_bin)} reload"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Monitor Crono monit-service'
|
22
|
+
task :monitor do
|
23
|
+
on roles(fetch(:crono_role)) do
|
24
|
+
begin
|
25
|
+
sudo_if_needed "#{fetch(:crono_monit_bin)} monitor #{crono_monit_service_name}"
|
26
|
+
rescue
|
27
|
+
invoke 'crono:monit:config'
|
28
|
+
sudo_if_needed "#{fetch(:crono_monit_bin)} monitor #{crono_monit_service_name}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Unmonitor Crono monit-service'
|
34
|
+
task :unmonitor do
|
35
|
+
on roles(fetch(:crono_role)) do
|
36
|
+
begin
|
37
|
+
sudo_if_needed "#{fetch(:crono_monit_bin)} unmonitor #{crono_monit_service_name}"
|
38
|
+
rescue
|
39
|
+
# no worries here (still no monitoring)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Start Crono monit-service'
|
45
|
+
task :start do
|
46
|
+
on roles(fetch(:crono_role)) do
|
47
|
+
sudo_if_needed "#{fetch(:crono_monit_bin)} start #{crono_monit_service_name}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Stop Crono monit-service'
|
52
|
+
task :stop do
|
53
|
+
on roles(fetch(:crono_role)) do
|
54
|
+
sudo_if_needed "#{fetch(:crono_monit_bin)} stop #{crono_monit_service_name}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc 'Restart Crono monit-service'
|
59
|
+
task :restart do
|
60
|
+
on roles(fetch(:crono_role)) do
|
61
|
+
sudo_if_needed "#{fetch(:crono_monit_bin)} restart #{crono_monit_service_name}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
before 'deploy:updating', 'crono:monit:unmonitor'
|
66
|
+
after 'deploy:published', 'crono:monit:monitor'
|
67
|
+
|
68
|
+
def crono_monit_service_name
|
69
|
+
fetch(:crono_monit_service_name, "crono_#{fetch(:application)}_#{fetch(:stage)}")
|
70
|
+
end
|
71
|
+
|
72
|
+
def sudo_if_needed(command)
|
73
|
+
if fetch(:crono_monit_use_sudo)
|
74
|
+
sudo command
|
75
|
+
else
|
76
|
+
execute command
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def template_crono(from, to)
|
84
|
+
[
|
85
|
+
"lib/capistrano/templates/#{from}.erb",
|
86
|
+
"config/deploy/templates/#{from}.erb",
|
87
|
+
File.expand_path("../../templates/#{from}.erb", __FILE__)
|
88
|
+
].each do |path|
|
89
|
+
if File.file?(path)
|
90
|
+
erb = File.read(path)
|
91
|
+
upload! StringIO.new(ERB.new(erb, nil, '-').result(binding)), to
|
92
|
+
break
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Monit configuration for Crono
|
2
|
+
# Service name: <%= crono_monit_service_name %>
|
3
|
+
#
|
4
|
+
check process <%= crono_monit_service_name %>
|
5
|
+
with pidfile "<%= fetch(:crono_pid) %>"
|
6
|
+
start program = "/usr/bin/sudo -iu <%= @role.user %> /bin/bash -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:bundle] %> exec crono start --daemonize --pidfile <%= fetch(:crono_pid) %> --logfile <%= fetch(:crono_log) %> --environment <%= fetch(:crono_env) %>'"
|
7
|
+
stop program = "/usr/bin/sudo -iu <%= @role.user %> /bin/bash -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:bundle] %> exec crono stop --daemonize --pidfile <%= fetch(:crono_pid) %> --logfile <%= fetch(:crono_log) %> --environment <%= fetch(:crono_env) %>'"
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module Crono
|
3
|
+
module Monit
|
4
|
+
module Generators
|
5
|
+
class TemplateGenerator < Rails::Generators::Base
|
6
|
+
|
7
|
+
namespace "capistrano:crono:monit:template"
|
8
|
+
desc "Create local monitrc.erb, and erb files for monitored processes for customization"
|
9
|
+
source_root File.expand_path('../../../../../capistrano/templates', __FILE__)
|
10
|
+
argument :templates_path, type: :string,
|
11
|
+
default: "config/deploy/templates",
|
12
|
+
banner: "path to templates"
|
13
|
+
|
14
|
+
def copy_template
|
15
|
+
copy_file "crono_monit.conf.erb", "#{templates_path}/crono_monit.erb"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-crono-monit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michal Mrozek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: capistrano-crono
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.1.2
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.1.2
|
47
|
+
description: Monit integration with capistrano-crono
|
48
|
+
email:
|
49
|
+
- michalmrozek@wp.pl
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- ".gitignore"
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- capistrano-crono-monit.gemspec
|
60
|
+
- lib/capistrano-crono-monit.rb
|
61
|
+
- lib/capistrano/crono/monit.rb
|
62
|
+
- lib/capistrano/crono/monit/version.rb
|
63
|
+
- lib/capistrano/crono/tasks/monit.rake
|
64
|
+
- lib/capistrano/crono/templates/crono_monit.conf.erb
|
65
|
+
- lib/generators/capistrano/crono/monit/template_generator.rb
|
66
|
+
homepage: https://github.com/Michsior14/capistrano-crono-monit
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.9.3
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.5.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Monit integration with capistrano-crono
|
90
|
+
test_files: []
|