capistrano-o2web-recipes 0.1.0 → 0.1.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 140e55a898f8910d2f6d3ccb975b39d67360f9bc
|
4
|
+
data.tar.gz: 153ef8d64072b53ac7219a1860a18a4cc61d48a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7c71c4a88cd6c7f569f2dbeb65e630328707082a492b56cb61f7dfdaacf3fd381323444ec230324d1c50dd5e6104659feed9feda2e04737243cff199cb2c13e
|
7
|
+
data.tar.gz: e36edddf8af692d6356012daf2c5761a1f2e5c4689d8548d6564a47c543c314719f490a31b61d7a929011a8dd824374e2029f3fecabedf0af15f2b11ca20e00d
|
data/README.md
CHANGED
@@ -58,11 +58,11 @@ set :files_private_dirs, fetch(:files_private_dirs).push(*%W[
|
|
58
58
|
])
|
59
59
|
set :nginx_max_body_size, '10m'
|
60
60
|
# default to ['system', 'images']
|
61
|
-
set :
|
61
|
+
set :nginx_public_dirs, fetch(:nginx_public_dirs).push(*%W[
|
62
62
|
spree
|
63
63
|
])
|
64
64
|
# default to ['404.html', '422.html', '500.html', 'favicon.ico']
|
65
|
-
set :
|
65
|
+
set :nginx_public_files, fetch(:nginx_public_files).push(*%W[
|
66
66
|
])
|
67
67
|
# default to {}
|
68
68
|
set :nginx_redirects, fetch(:nginx_redirects).merge({
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module Helpers
|
3
|
+
module Rsync
|
4
|
+
def send_files(type, server, root = 'public')
|
5
|
+
raise "No server given" if !server
|
6
|
+
system "rsync --progress -rue 'ssh -p #{fetch(:port)}' #{root}/#{type} #{server.user}@#{server.hostname}:#{shared_path}/#{root}/"
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_files(type, server, root = 'public')
|
10
|
+
raise "No server given" if !server
|
11
|
+
puts "Importing #{type}. Please wait..."
|
12
|
+
system "rsync --progress -rue 'ssh -p #{fetch(:port)}' #{server.user}@#{server.hostname}:#{shared_path}/#{root}/#{type} ./#{root}/"
|
13
|
+
end
|
14
|
+
|
15
|
+
def upload(server, source, destination)
|
16
|
+
File.open(source, 'w') do |f|
|
17
|
+
f.puts ERB.new(File.read("#{source}.erb"), nil, '-').result
|
18
|
+
end
|
19
|
+
system "rsync --rsync-path='sudo rsync' -avzO -e 'ssh -p #{fetch(:port)}' '#{source}' #{fetch(:deployer_name)}@#{server.hostname}:#{destination}"
|
20
|
+
FileUtils.rm_f source
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'erb'
|
2
|
+
require 'capistrano/helpers/rsync'
|
3
|
+
|
4
|
+
include Capistrano::Helpers::Rsync
|
2
5
|
|
3
6
|
namespace :load do
|
4
7
|
task :defaults do
|
@@ -80,17 +83,6 @@ namespace :tmp_cache do
|
|
80
83
|
end
|
81
84
|
|
82
85
|
namespace :files do
|
83
|
-
def send_files(type, server, root = 'public')
|
84
|
-
raise "No server given" if !server
|
85
|
-
system "rsync --progress -rue 'ssh -p #{fetch(:port)}' #{root}/#{type} #{server.user}@#{server.hostname}:#{shared_path}/#{root}/"
|
86
|
-
end
|
87
|
-
|
88
|
-
def get_files(type, server, root = 'public')
|
89
|
-
raise "No server given" if !server
|
90
|
-
puts "Importing #{type}. Please wait..."
|
91
|
-
system "rsync --progress -rue 'ssh -p #{fetch(:port)}' #{server.user}@#{server.hostname}:#{shared_path}/#{root}/#{type} ./#{root}/"
|
92
|
-
end
|
93
|
-
|
94
86
|
desc 'Import public files'
|
95
87
|
task :server_to_local do
|
96
88
|
on roles :app do |host|
|
@@ -161,14 +153,6 @@ namespace :db do
|
|
161
153
|
end
|
162
154
|
|
163
155
|
namespace :nginx do
|
164
|
-
def upload(server, source, destination)
|
165
|
-
File.open(source, 'w') do |f|
|
166
|
-
f.puts ERB.new(File.read("#{source}.erb"), nil, '-').result
|
167
|
-
end
|
168
|
-
system "rsync --rsync-path='sudo rsync' -avzO -e 'ssh -p #{fetch(:port)}' '#{source}' #{fetch(:deployer_name)}@#{server.hostname}:#{destination}"
|
169
|
-
FileUtils.rm_f source
|
170
|
-
end
|
171
|
-
|
172
156
|
desc 'Export nginx configuration files'
|
173
157
|
task :local_to_server do
|
174
158
|
on roles :app do |host|
|
@@ -177,3 +161,35 @@ namespace :nginx do
|
|
177
161
|
end
|
178
162
|
end
|
179
163
|
end
|
164
|
+
|
165
|
+
namespace :monit do
|
166
|
+
desc 'Export monit configuration file'
|
167
|
+
task :local_to_server do
|
168
|
+
on roles :app do |host|
|
169
|
+
upload host, 'config/monitrc', '/etc/monit/monitrc'
|
170
|
+
execute :sudo, 'chown root:root /etc/monit/monitrc'
|
171
|
+
execute :sudo, 'chmod 0700 /etc/monit/monitrc'
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
desc 'Start monit'
|
176
|
+
task :start do
|
177
|
+
on roles :app do |host|
|
178
|
+
execute :sudo, 'monit start all'
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
desc 'Stop monit'
|
183
|
+
task :stop do
|
184
|
+
on roles :app do |host|
|
185
|
+
execute :sudo, 'monit stop all'
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
desc 'Reload monit'
|
190
|
+
task :reload do
|
191
|
+
on roles :app do |host|
|
192
|
+
execute :sudo, 'monit reload'
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
@@ -0,0 +1,253 @@
|
|
1
|
+
###############################################################################
|
2
|
+
## Monit control file
|
3
|
+
###############################################################################
|
4
|
+
##
|
5
|
+
## Comments begin with a '#' and extend through the end of the line. Keywords
|
6
|
+
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
|
7
|
+
##
|
8
|
+
## Below you will find examples of some frequently used statements. For
|
9
|
+
## information about the control file and a complete list of statements and
|
10
|
+
## options, please have a look in the Monit manual.
|
11
|
+
##
|
12
|
+
##
|
13
|
+
###############################################################################
|
14
|
+
## Global section
|
15
|
+
###############################################################################
|
16
|
+
##
|
17
|
+
## Start Monit in the background (run as a daemon):
|
18
|
+
#
|
19
|
+
set daemon 120 # check services at 2-minute intervals
|
20
|
+
# with start delay 240 # optional: delay the first check by 4-minutes (by
|
21
|
+
# # default Monit check immediately after Monit start)
|
22
|
+
#
|
23
|
+
#
|
24
|
+
## Set syslog logging with the 'daemon' facility. If the FACILITY option is
|
25
|
+
## omitted, Monit will use 'user' facility by default. If you want to log to
|
26
|
+
## a standalone log file instead, specify the full path to the log file
|
27
|
+
#
|
28
|
+
# set logfile syslog facility log_daemon
|
29
|
+
set logfile /var/log/monit.log
|
30
|
+
#
|
31
|
+
#
|
32
|
+
## Set the location of the Monit id file which stores the unique id for the
|
33
|
+
## Monit instance. The id is generated and stored on first Monit start. By
|
34
|
+
## default the file is placed in $HOME/.monit.id.
|
35
|
+
#
|
36
|
+
# set idfile /var/.monit.id
|
37
|
+
set idfile /var/lib/monit/id
|
38
|
+
#
|
39
|
+
## Set the location of the Monit state file which saves monitoring states
|
40
|
+
## on each cycle. By default the file is placed in $HOME/.monit.state. If
|
41
|
+
## the state file is stored on a persistent filesystem, Monit will recover
|
42
|
+
## the monitoring state across reboots. If it is on temporary filesystem, the
|
43
|
+
## state will be lost on reboot which may be convenient in some situations.
|
44
|
+
#
|
45
|
+
set statefile /var/lib/monit/state
|
46
|
+
#
|
47
|
+
## Set the list of mail servers for alert delivery. Multiple servers may be
|
48
|
+
## specified using a comma separator. If the first mail server fails, Monit
|
49
|
+
# will use the second mail server in the list and so on. By default Monit uses
|
50
|
+
# port 25 - it is possible to override this with the PORT option.
|
51
|
+
#
|
52
|
+
# set mailserver mail.bar.baz, # primary mailserver
|
53
|
+
# backup.bar.baz port 10025, # backup mailserver on port 10025
|
54
|
+
# localhost # fallback relay
|
55
|
+
#
|
56
|
+
#
|
57
|
+
## By default Monit will drop alert events if no mail servers are available.
|
58
|
+
## If you want to keep the alerts for later delivery retry, you can use the
|
59
|
+
## EVENTQUEUE statement. The base directory where undelivered alerts will be
|
60
|
+
## stored is specified by the BASEDIR option. You can limit the maximal queue
|
61
|
+
## size using the SLOTS option (if omitted, the queue is limited by space
|
62
|
+
## available in the back end filesystem).
|
63
|
+
#
|
64
|
+
set eventqueue
|
65
|
+
basedir /var/lib/monit/events # set the base directory where events will be stored
|
66
|
+
slots 100 # optionally limit the queue size
|
67
|
+
#
|
68
|
+
#
|
69
|
+
## Send status and events to M/Monit (for more informations about M/Monit
|
70
|
+
## see http://mmonit.com/). By default Monit registers credentials with
|
71
|
+
## M/Monit so M/Monit can smoothly communicate back to Monit and you don't
|
72
|
+
## have to register Monit credentials manually in M/Monit. It is possible to
|
73
|
+
## disable credential registration using the commented out option below.
|
74
|
+
## Though, if safety is a concern we recommend instead using https when
|
75
|
+
## communicating with M/Monit and send credentials encrypted.
|
76
|
+
#
|
77
|
+
# set mmonit http://monit:monit@192.168.1.10:8080/collector
|
78
|
+
# # and register without credentials # Don't register credentials
|
79
|
+
#
|
80
|
+
#
|
81
|
+
## Monit by default uses the following format for alerts if the the mail-format
|
82
|
+
## statement is missing::
|
83
|
+
## --8<--
|
84
|
+
## set mail-format {
|
85
|
+
## from: monit@$HOST
|
86
|
+
## subject: monit alert -- $EVENT $SERVICE
|
87
|
+
## message: $EVENT Service $SERVICE
|
88
|
+
## Date: $DATE
|
89
|
+
## Action: $ACTION
|
90
|
+
## Host: $HOST
|
91
|
+
## Description: $DESCRIPTION
|
92
|
+
##
|
93
|
+
## Your faithful employee,
|
94
|
+
## Monit
|
95
|
+
## }
|
96
|
+
## --8<--
|
97
|
+
##
|
98
|
+
## You can override this message format or parts of it, such as subject
|
99
|
+
## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
|
100
|
+
## are expanded at runtime. For example, to override the sender, use:
|
101
|
+
#
|
102
|
+
# set mail-format { from: monit@foo.bar }
|
103
|
+
#
|
104
|
+
#
|
105
|
+
## You can set alert recipients whom will receive alerts if/when a
|
106
|
+
## service defined in this file has errors. Alerts may be restricted on
|
107
|
+
## events by using a filter as in the second example below.
|
108
|
+
#
|
109
|
+
# set alert sysadm@foo.bar # receive all alerts
|
110
|
+
## Do not alert when Monit start,stop or perform a user initiated action
|
111
|
+
# set alert manager@foo.bar not on { instance, action }
|
112
|
+
#
|
113
|
+
#
|
114
|
+
## Monit has an embedded web server which can be used to view status of
|
115
|
+
## services monitored and manage services from a web interface. See the
|
116
|
+
## Monit Wiki if you want to enable SSL for the web server.
|
117
|
+
#
|
118
|
+
set httpd port 2812 and
|
119
|
+
use address localhost # only accept connection from localhost
|
120
|
+
allow localhost # allow localhost to connect to the server and
|
121
|
+
allow admin:monit # require user 'admin' with password 'monit'
|
122
|
+
allow @monit # allow users of group 'monit' to connect (rw)
|
123
|
+
allow @users readonly # allow users of group 'users' to connect readonly
|
124
|
+
#
|
125
|
+
###############################################################################
|
126
|
+
## Services
|
127
|
+
###############################################################################
|
128
|
+
##
|
129
|
+
## Check general system resources such as load average, cpu and memory
|
130
|
+
## usage. Each test specifies a resource, conditions and the action to be
|
131
|
+
## performed should a test fail.
|
132
|
+
#
|
133
|
+
# check system myhost.mydomain.tld
|
134
|
+
# if loadavg (1min) > 4 then alert
|
135
|
+
# if loadavg (5min) > 2 then alert
|
136
|
+
# if memory usage > 75% then alert
|
137
|
+
# if swap usage > 25% then alert
|
138
|
+
# if cpu usage (user) > 70% then alert
|
139
|
+
# if cpu usage (system) > 30% then alert
|
140
|
+
# if cpu usage (wait) > 20% then alert
|
141
|
+
#
|
142
|
+
#
|
143
|
+
## Check if a file exists, checksum, permissions, uid and gid. In addition
|
144
|
+
## to alert recipients in the global section, customized alert can be sent to
|
145
|
+
## additional recipients by specifying a local alert handler. The service may
|
146
|
+
## be grouped using the GROUP option. More than one group can be specified by
|
147
|
+
## repeating the 'group name' statement.
|
148
|
+
#
|
149
|
+
# check file apache_bin with path /usr/local/apache/bin/httpd
|
150
|
+
# if failed checksum and
|
151
|
+
# expect the sum 8f7f419955cefa0b33a2ba316cba3659 then unmonitor
|
152
|
+
# if failed permission 755 then unmonitor
|
153
|
+
# if failed uid root then unmonitor
|
154
|
+
# if failed gid root then unmonitor
|
155
|
+
# alert security@foo.bar on {
|
156
|
+
# checksum, permission, uid, gid, unmonitor
|
157
|
+
# } with the mail-format { subject: Alarm! }
|
158
|
+
# group server
|
159
|
+
#
|
160
|
+
#
|
161
|
+
## Check that a process is running, in this case Apache, and that it respond
|
162
|
+
## to HTTP and HTTPS requests. Check its resource usage such as cpu and memory,
|
163
|
+
## and number of children. If the process is not running, Monit will restart
|
164
|
+
## it by default. In case the service is restarted very often and the
|
165
|
+
## problem remains, it is possible to disable monitoring using the TIMEOUT
|
166
|
+
## statement. This service depends on another service (apache_bin) which
|
167
|
+
## is defined above.
|
168
|
+
#
|
169
|
+
# check process apache with pidfile /usr/local/apache/logs/httpd.pid
|
170
|
+
# start program = "/etc/init.d/httpd start" with timeout 60 seconds
|
171
|
+
# stop program = "/etc/init.d/httpd stop"
|
172
|
+
# if cpu > 60% for 2 cycles then alert
|
173
|
+
# if cpu > 80% for 5 cycles then restart
|
174
|
+
# if totalmem > 200.0 MB for 5 cycles then restart
|
175
|
+
# if children > 250 then restart
|
176
|
+
# if loadavg(5min) greater than 10 for 8 cycles then stop
|
177
|
+
# if failed host www.tildeslash.com port 80 protocol http
|
178
|
+
# and request "/somefile.html"
|
179
|
+
# then restart
|
180
|
+
# if failed port 443 type tcpssl protocol http
|
181
|
+
# with timeout 15 seconds
|
182
|
+
# then restart
|
183
|
+
# if 3 restarts within 5 cycles then timeout
|
184
|
+
# depends on apache_bin
|
185
|
+
# group server
|
186
|
+
#
|
187
|
+
#
|
188
|
+
## Check filesystem permissions, uid, gid, space and inode usage. Other services,
|
189
|
+
## such as databases, may depend on this resource and an automatically graceful
|
190
|
+
## stop may be cascaded to them before the filesystem will become full and data
|
191
|
+
## lost.
|
192
|
+
#
|
193
|
+
# check filesystem datafs with path /dev/sdb1
|
194
|
+
# start program = "/bin/mount /data"
|
195
|
+
# stop program = "/bin/umount /data"
|
196
|
+
# if failed permission 660 then unmonitor
|
197
|
+
# if failed uid root then unmonitor
|
198
|
+
# if failed gid disk then unmonitor
|
199
|
+
# if space usage > 80% for 5 times within 15 cycles then alert
|
200
|
+
# if space usage > 99% then stop
|
201
|
+
# if inode usage > 30000 then alert
|
202
|
+
# if inode usage > 99% then stop
|
203
|
+
# group server
|
204
|
+
#
|
205
|
+
#
|
206
|
+
## Check a file's timestamp. In this example, we test if a file is older
|
207
|
+
## than 15 minutes and assume something is wrong if its not updated. Also,
|
208
|
+
## if the file size exceed a given limit, execute a script
|
209
|
+
#
|
210
|
+
# check file database with path /data/mydatabase.db
|
211
|
+
# if failed permission 700 then alert
|
212
|
+
# if failed uid data then alert
|
213
|
+
# if failed gid data then alert
|
214
|
+
# if timestamp > 15 minutes then alert
|
215
|
+
# if size > 100 MB then exec "/my/cleanup/script" as uid dba and gid dba
|
216
|
+
#
|
217
|
+
#
|
218
|
+
## Check directory permission, uid and gid. An event is triggered if the
|
219
|
+
## directory does not belong to the user with uid 0 and gid 0. In addition,
|
220
|
+
## the permissions have to match the octal description of 755 (see chmod(1)).
|
221
|
+
#
|
222
|
+
# check directory bin with path /bin
|
223
|
+
# if failed permission 755 then unmonitor
|
224
|
+
# if failed uid 0 then unmonitor
|
225
|
+
# if failed gid 0 then unmonitor
|
226
|
+
#
|
227
|
+
#
|
228
|
+
## Check a remote host availability by issuing a ping test and check the
|
229
|
+
## content of a response from a web server. Up to three pings are sent and
|
230
|
+
## connection to a port and an application level network check is performed.
|
231
|
+
#
|
232
|
+
# check host myserver with address 192.168.1.1
|
233
|
+
# if failed icmp type echo count 3 with timeout 3 seconds then alert
|
234
|
+
# if failed port 3306 protocol mysql with timeout 15 seconds then alert
|
235
|
+
# if failed url http://user:password@www.foo.bar:8080/?querystring
|
236
|
+
# and content == 'action="j_security_check"'
|
237
|
+
# then alert
|
238
|
+
#
|
239
|
+
#
|
240
|
+
check process nginx with pidfile /var/run/nginx.pid
|
241
|
+
start program = "/etc/init.d/nginx start"
|
242
|
+
stop program = "/etc/init.d/nginx stop"
|
243
|
+
if cpu > 80% for 5 cycles then restart
|
244
|
+
|
245
|
+
###############################################################################
|
246
|
+
## Includes
|
247
|
+
###############################################################################
|
248
|
+
##
|
249
|
+
## It is possible to include additional configuration parts from other files or
|
250
|
+
## directories.
|
251
|
+
#
|
252
|
+
include /etc/monit/conf.d/*
|
253
|
+
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-o2web-recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrice Lebel
|
@@ -66,11 +66,13 @@ files:
|
|
66
66
|
- Rakefile
|
67
67
|
- capistrano-o2web-recipes.gemspec
|
68
68
|
- lib/capistrano-o2web-recipes.rb
|
69
|
+
- lib/capistrano/helpers/rsync.rb
|
69
70
|
- lib/capistrano/o2web_recipes.rb
|
70
71
|
- lib/capistrano/o2web_recipes/version.rb
|
71
72
|
- lib/capistrano/tasks/o2web_recipes.rake
|
72
73
|
- lib/generators/capistrano/o2web_recipes/install/USAGE.md
|
73
74
|
- lib/generators/capistrano/o2web_recipes/install/install_generator.rb
|
75
|
+
- lib/generators/capistrano/o2web_recipes/install/templates/config/monitrc.erb
|
74
76
|
- lib/generators/capistrano/o2web_recipes/install/templates/config/nginx.app.conf.erb
|
75
77
|
- lib/generators/capistrano/o2web_recipes/install/templates/config/nginx.conf.erb
|
76
78
|
homepage: https://github.com/o2web/capistrano-o2web-recipes
|
@@ -92,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
94
|
version: '0'
|
93
95
|
requirements: []
|
94
96
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.2.2
|
96
98
|
signing_key:
|
97
99
|
specification_version: 4
|
98
100
|
summary: Common Capistrano Recipes used by O2Web.
|
99
101
|
test_files: []
|
100
|
-
has_rdoc:
|