capistrano-vmf 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 087063aae0a3a65a151b4e8a192a2c7c18e015ed
4
+ data.tar.gz: ddd374fd82f99130a3038ceb2db689a2af73ade1
5
+ SHA512:
6
+ metadata.gz: e3846fda2192445f0e67e82e86b155db21541db8d0ce0c3cf10e3026fdd50627942c5d41743589f25eb860f40be5b5e6472346beabf4668d1afd0d8bb3a3d0a9
7
+ data.tar.gz: b3b5dda8ba42aaa496db7a862c0849855ace07135c1f866d5cc2a9a8d1c8ff11dd0a09380e4be50e2315a585ef6e7157f5341fe6e11e118cb59d776a10a4f57a
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-vmf.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sean Walberg
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # Capistrano::Vmf
2
+
3
+ [VMFarms.com](http://vmfarms.com) integration for bundler. If you're deploying a Rails app to VMFarms then this is a set of tasks that will conform to their best practices, and some generators that get you the most out of your hosting.
4
+
5
+ In particular,
6
+
7
+ * Unicorn server configured for zero downtime restarts
8
+ * Default directories already configured
9
+ * Installs Ruby and sets as default
10
+ * Generators to configure NewRelic
11
+
12
+ ## Installation
13
+
14
+ Once you've got Capistrano installed,
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'capistrano-vmf'
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ ## Usage
25
+
26
+ Require in `Capfile` to use the default task:
27
+
28
+ require 'capistrano/vmf'
29
+
30
+ For your `config/deploy.rb`, you'll want as a minimum:
31
+ ```
32
+ # Point cap to your application
33
+ lock '3.1.0'
34
+ set :application, 'vmftest'
35
+ set :repo_url, 'git@bitbucket.org:yourname/repo.git'
36
+ set :pty, true
37
+
38
+ set :rvm1_ruby_version, "2.0.0-p247"
39
+ ```
40
+
41
+ Then, in each `config/deploy/*.rb` (corresponding to your environment)
42
+ ```
43
+ # The list of servers, one line each
44
+ server '1.2.3.4', user: 'deploy', roles: %w{web app}
45
+ # The primary domain name of this environment, that you gave to VMF
46
+ set :site_name, "vmf.ertw.com"
47
+ # The list of services that get restarted.
48
+ set :supervisor_services, %w[unicorn resque-dev]
49
+ ```
50
+
51
+ Note that options set in `deploy.rb` are overridden in the environment file, and all these options are valid at either level.
52
+
53
+ Configurable options:
54
+ ```
55
+ set :ruby_version, "2.0.0-p247" # Pick the version of Ruby you'll use
56
+ set :site_name, "test.example.com" # The hostname of your application (VMF has this, too)
57
+ # Each environment will probably have it's own in `config/deploy/*.rb`
58
+ set :supervisor_services, %q[unicorn resque] # the list of services to restart (supervisord)
59
+
60
+ ```
61
+
62
+ ## Generators
63
+
64
+ This gem provides two generators that set up Unicorn and NewRelic RPM according to VMFarms recommended configuration.
65
+
66
+ ### Unicorn
67
+
68
+ [Unicorn](unicorn.bogomips.org) is a high performance application server that allows you to restart your application with zero downtime. When you restart, a new set of unicorn processes are spun up leaving the old ones to handle requests. The new servers start taking requests when the booting is complete, then the old servers are killed. VMFarms has special configuration on their side to do the zero downtime restarts correctly.
69
+
70
+ To use Unicorn in your application, run
71
+
72
+ bundle exec rails generate vmf:unicorn
73
+ bundle install
74
+
75
+ It will update your Gemfile and add a `config/unicorn.rb`. By default 4 application servers are run but this is easily changed by talking to VMFarms support.
76
+
77
+ ### NewRelic
78
+
79
+ VMFarms has a partnership with [NewRelic](http://newrelic.com/) to give you free access to a standard account which provides detailed application performance monitoring. You will need a license key from VMFarms, then run
80
+
81
+ bundle exec rails generate vmf:newrelic
82
+ bundle install
83
+
84
+ You will be prompted for the licence key.
85
+
86
+
87
+ ## Other stuff
88
+
89
+ Have a Redis server? Define it:
90
+
91
+ server 'user@redisserver', roles: %w{redis}, no_release: true
92
+
93
+ Then you have two tasks:
94
+
95
+ redis:keys - shows all the keys
96
+ redis:flush - flush all the Redis keys
97
+
98
+ Do you want to store secrets in a config file on the server?
99
+
100
+ set :linked_files, %w{config/database.yml} # in your deploy
101
+ set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} # Same for directories
102
+
103
+ Then copy the local file config/database.yml to all your servers
104
+ cap production files:copy[config/database.yml] # copies local database.yml to all servers
105
+
106
+ ## Contributing
107
+
108
+ 1. Fork it
109
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
110
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
111
+ 4. Push to the branch (`git push origin my-new-feature`)
112
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "capistrano-vmf"
7
+ spec.version = "1.0.1"
8
+ spec.authors = ["Sean Walberg"]
9
+ spec.email = ["sean@ertw.com"]
10
+ spec.description = %q{Some capistrano automation to handle apps deployed to VMFarms}
11
+ spec.summary = %q{Some capistrano automation to handle apps deployed to VMFarms}
12
+ spec.homepage = "https://github.com/swalberg/capistrano-vmf"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+
23
+ spec.add_dependency "capistrano", "~> 3.0"
24
+ spec.add_dependency "rvm1-capistrano3"
25
+ end
@@ -0,0 +1,12 @@
1
+ namespace :files do
2
+ desc "Copy a local file to the shared directory of the server"
3
+ task :copy, :file do |task, args|
4
+ on release_roles(:all), except: { no_release: true } do
5
+ if args[:file].nil?
6
+ puts "cap <environment> files:copy[config/foo.yml]"
7
+ else
8
+ upload! args[:file], "#{shared_path}/#{args[:file]}"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ namespace :redis do
2
+ desc "List all keys"
3
+ task :keys do |task|
4
+ on roles(:redis), in: :parallel do
5
+ set :default_shell, "/bin/bash"
6
+ puts capture "/usr/bin/redis-cli keys '*'"
7
+ end
8
+ end
9
+
10
+ desc "Flush all keys"
11
+ task :flush do |task|
12
+ on roles(:redis), in: :parallel do
13
+ set :default_shell, "/bin/bash"
14
+ puts capture "/usr/bin/redis-cli flushdb"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ include Capistrano::DSL
2
+ namespace :load do
3
+ task :defaults do
4
+ set :deploy_to, -> { "/data/web/#{fetch(:site_name)}" }
5
+ fetch(:default_env).merge!( rvm_path: "/data/rvm" )
6
+ end
7
+ end
8
+ namespace :deploy do
9
+
10
+ desc 'Restart VMF services'
11
+ task :restart_vmf_services do
12
+ on roles(:app), in: :sequence, wait: 5 do
13
+ # Your restart mechanism here, for example:
14
+ Array(fetch(:supervisor_services)).each do |service|
15
+ execute :sudo, "supervisorctl", "restart", service
16
+ end
17
+ end
18
+ end
19
+
20
+ after :publishing, :restart_vmf_services
21
+
22
+ end
23
+
@@ -0,0 +1,8 @@
1
+ require 'capistrano/all'
2
+ require 'capistrano/setup'
3
+ require 'capistrano/deploy'
4
+
5
+ require 'rvm1/capistrano3'
6
+ load File.expand_path('../tasks/vmf.cap', __FILE__)
7
+ load File.expand_path('../tasks/redis.cap', __FILE__)
8
+ load File.expand_path('../tasks/files.cap', __FILE__)
@@ -0,0 +1,11 @@
1
+ class Vmf::NewrelicGenerator < Rails::Generators::Base
2
+ source_root File.expand_path("../../../../templates", __FILE__)
3
+
4
+ def install_newrelic
5
+ print "Please enter your NewRelic license key: "
6
+ @license_key = STDIN.gets.chomp
7
+ template "newrelic.yml.erb", "config/newrelic.yml"
8
+
9
+ gem "newrelic_rpm"
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class Vmf::UnicornGenerator < Rails::Generators::Base
2
+ source_root File.expand_path("../../../../templates", __FILE__)
3
+
4
+ def install_unicorn
5
+ template "unicorn.rb.erb", "config/unicorn.rb"
6
+
7
+ gem "unicorn"
8
+ end
9
+ end
@@ -0,0 +1,228 @@
1
+ #
2
+ # This file configures the New Relic Agent. New Relic monitors
3
+ # Ruby, Java, .NET, PHP, and Python applications with deep visibility and low overhead.
4
+ # For more information, visit www.newrelic.com.
5
+ #
6
+ # Generated March 15, 2014
7
+ #
8
+ # This configuration file is custom generated for sean@ertw.com
9
+
10
+
11
+ # Here are the settings that are common to all environments
12
+ common: &default_settings
13
+ # ============================== LICENSE KEY ===============================
14
+
15
+ # You must specify the license key associated with your New Relic
16
+ # account. This key binds your Agent's data to your account in the
17
+ # New Relic service.
18
+ license_key: '<%= @license_key %>'
19
+
20
+ # Agent Enabled (Ruby/Rails Only)
21
+ # Use this setting to force the agent to run or not run.
22
+ # Default is 'auto' which means the agent will install and run only
23
+ # if a valid dispatcher such as Mongrel is running. This prevents
24
+ # it from running with Rake or the console. Set to false to
25
+ # completely turn the agent off regardless of the other settings.
26
+ # Valid values are true, false and auto.
27
+ #
28
+ # agent_enabled: auto
29
+
30
+ # Application Name Set this to be the name of your application as
31
+ # you'd like it show up in New Relic. The service will then auto-map
32
+ # instances of your application into an "application" on your
33
+ # dashboard page. If you want to map this instance into multiple
34
+ # apps, like "AJAX Requests" and "All UI" then specify a semicolon
35
+ # separated list of up to three distinct names, or a yaml list.
36
+ # Defaults to the capitalized RAILS_ENV or RACK_ENV (i.e.,
37
+ # Production, Staging, etc)
38
+ #
39
+ # Example:
40
+ #
41
+ # app_name:
42
+ # - Ajax Service
43
+ # - All Services
44
+ #
45
+ app_name: My Application
46
+
47
+ # When "true", the agent collects performance data about your
48
+ # application and reports this data to the New Relic service at
49
+ # newrelic.com. This global switch is normally overridden for each
50
+ # environment below. (formerly called 'enabled')
51
+ monitor_mode: true
52
+
53
+ # Developer mode should be off in every environment but
54
+ # development as it has very high overhead in memory.
55
+ developer_mode: false
56
+
57
+ # The newrelic agent generates its own log file to keep its logging
58
+ # information separate from that of your application. Specify its
59
+ # log level here.
60
+ log_level: info
61
+
62
+ # Optionally set the path to the log file This is expanded from the
63
+ # root directory (may be relative or absolute, e.g. 'log/' or
64
+ # '/var/log/') The agent will attempt to create this directory if it
65
+ # does not exist.
66
+ # log_file_path: 'log'
67
+
68
+ # Optionally set the name of the log file, defaults to 'newrelic_agent.log'
69
+ # log_file_name: 'newrelic_agent.log'
70
+
71
+ # The newrelic agent communicates with the service via https by default. This
72
+ # prevents eavesdropping on the performance metrics transmitted by the agent.
73
+ # The encryption required by SSL introduces a nominal amount of CPU overhead,
74
+ # which is performed asynchronously in a background thread. If you'd prefer
75
+ # to send your metrics over http uncomment the following line.
76
+ # ssl: false
77
+
78
+ #============================== Browser Monitoring ===============================
79
+ # New Relic Real User Monitoring gives you insight into the performance real users are
80
+ # experiencing with your website. This is accomplished by measuring the time it takes for
81
+ # your users' browsers to download and render your web pages by injecting a small amount
82
+ # of JavaScript code into the header and footer of each page.
83
+ browser_monitoring:
84
+ # By default the agent automatically injects the monitoring JavaScript
85
+ # into web pages. Set this attribute to false to turn off this behavior.
86
+ auto_instrument: true
87
+
88
+ # Proxy settings for connecting to the New Relic server.
89
+ #
90
+ # If a proxy is used, the host setting is required. Other settings
91
+ # are optional. Default port is 8080.
92
+ #
93
+ # proxy_host: hostname
94
+ # proxy_port: 8080
95
+ # proxy_user:
96
+ # proxy_pass:
97
+
98
+ # The agent can optionally log all data it sends to New Relic servers to a
99
+ # separate log file for human inspection and auditing purposes. To enable this
100
+ # feature, change 'enabled' below to true.
101
+ # See: https://newrelic.com/docs/ruby/audit-log
102
+ audit_log:
103
+ enabled: false
104
+
105
+ # Tells transaction tracer and error collector (when enabled)
106
+ # whether or not to capture HTTP params. When true, frameworks can
107
+ # exclude HTTP parameters from being captured.
108
+ # Rails: the RoR filter_parameter_logging excludes parameters
109
+ # Java: create a config setting called "ignored_params" and set it to
110
+ # a comma separated list of HTTP parameter names.
111
+ # ex: ignored_params: credit_card, ssn, password
112
+ capture_params: false
113
+
114
+ # Transaction tracer captures deep information about slow
115
+ # transactions and sends this to the New Relic service once a
116
+ # minute. Included in the transaction is the exact call sequence of
117
+ # the transactions including any SQL statements issued.
118
+ transaction_tracer:
119
+
120
+ # Transaction tracer is enabled by default. Set this to false to
121
+ # turn it off. This feature is only available at the Professional
122
+ # and above product levels.
123
+ enabled: true
124
+
125
+ # Threshold in seconds for when to collect a transaction
126
+ # trace. When the response time of a controller action exceeds
127
+ # this threshold, a transaction trace will be recorded and sent to
128
+ # New Relic. Valid values are any float value, or (default) "apdex_f",
129
+ # which will use the threshold for an dissatisfying Apdex
130
+ # controller action - four times the Apdex T value.
131
+ transaction_threshold: apdex_f
132
+
133
+ # When transaction tracer is on, SQL statements can optionally be
134
+ # recorded. The recorder has three modes, "off" which sends no
135
+ # SQL, "raw" which sends the SQL statement in its original form,
136
+ # and "obfuscated", which strips out numeric and string literals.
137
+ record_sql: obfuscated
138
+
139
+ # Threshold in seconds for when to collect stack trace for a SQL
140
+ # call. In other words, when SQL statements exceed this threshold,
141
+ # then capture and send to New Relic the current stack trace. This is
142
+ # helpful for pinpointing where long SQL calls originate from.
143
+ stack_trace_threshold: 0.500
144
+
145
+ # Determines whether the agent will capture query plans for slow
146
+ # SQL queries. Only supported in mysql and postgres. Should be
147
+ # set to false when using other adapters.
148
+ # explain_enabled: true
149
+
150
+ # Threshold for query execution time below which query plans will
151
+ # not be captured. Relevant only when `explain_enabled` is true.
152
+ # explain_threshold: 0.5
153
+
154
+ # Error collector captures information about uncaught exceptions and
155
+ # sends them to New Relic for viewing
156
+ error_collector:
157
+
158
+ # Error collector is enabled by default. Set this to false to turn
159
+ # it off. This feature is only available at the Professional and above
160
+ # product levels.
161
+ enabled: true
162
+
163
+ # Rails Only - tells error collector whether or not to capture a
164
+ # source snippet around the place of the error when errors are View
165
+ # related.
166
+ capture_source: true
167
+
168
+ # To stop specific errors from reporting to New Relic, set this property
169
+ # to comma-separated values. Default is to ignore routing errors,
170
+ # which are how 404's get triggered.
171
+ ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
172
+
173
+ # If you're interested in capturing memcache keys as though they
174
+ # were SQL uncomment this flag. Note that this does increase
175
+ # overhead slightly on every memcached call, and can have security
176
+ # implications if your memcached keys are sensitive
177
+ # capture_memcache_keys: true
178
+
179
+ # Application Environments
180
+ # ------------------------------------------
181
+ # Environment-specific settings are in this section.
182
+ # For Rails applications, RAILS_ENV is used to determine the environment.
183
+ # For Java applications, pass -Dnewrelic.environment <environment> to set
184
+ # the environment.
185
+
186
+ # NOTE if your application has other named environments, you should
187
+ # provide newrelic configuration settings for these environments here.
188
+
189
+ development:
190
+ <<: *default_settings
191
+ # Turn off communication to New Relic service in development mode (also
192
+ # 'enabled').
193
+ # NOTE: for initial evaluation purposes, you may want to temporarily
194
+ # turn the agent on in development mode.
195
+ monitor_mode: false
196
+
197
+ # Rails Only - when running in Developer Mode, the New Relic Agent will
198
+ # present performance information on the last 100 transactions you have
199
+ # executed since starting the mongrel.
200
+ # NOTE: There is substantial overhead when running in developer mode.
201
+ # Do not use for production or load testing.
202
+ developer_mode: true
203
+
204
+ # Enable textmate links
205
+ # textmate: true
206
+
207
+ test:
208
+ <<: *default_settings
209
+ # It almost never makes sense to turn on the agent when running
210
+ # unit, functional or integration tests or the like.
211
+ monitor_mode: false
212
+
213
+ # Turn on the agent in production for 24x7 monitoring. NewRelic
214
+ # testing shows an average performance impact of < 5 ms per
215
+ # transaction, you can leave this on all the time without
216
+ # incurring any user-visible performance degradation.
217
+ production:
218
+ <<: *default_settings
219
+ monitor_mode: true
220
+
221
+ # Many applications have a staging environment which behaves
222
+ # identically to production. Support for that environment is provided
223
+ # here. By default, the staging environment has the agent turned on.
224
+ staging:
225
+ <<: *default_settings
226
+ monitor_mode: true
227
+ # app_name: My Application (Staging)
228
+
@@ -0,0 +1,101 @@
1
+ # Sample verbose configuration file for Unicorn (not Rack)
2
+ #
3
+ # This configuration file documents many features of Unicorn
4
+ # that may not be needed for some applications. See
5
+ # http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
6
+ # for a much simpler configuration file.
7
+ #
8
+ # See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
9
+ # documentation.
10
+
11
+ # Use at least one worker per core if you're on a dedicated server,
12
+ # more will usually help for _short_ waits on databases/caches.
13
+ worker_processes(ENV['UNICORN_WORKERS'] ? ENV['UNICORN_WORKERS'].to_i : 4)
14
+ # Since Unicorn is never exposed to outside clients, it does not need to
15
+ # run on the standard HTTP port (80), there is no reason to start Unicorn
16
+ # as root unless it's from system init scripts.
17
+ # If running the master process as root and the workers as an unprivileged
18
+ # user, do this to switch euid/egid in the workers (also chowns logs):
19
+ # user "unprivileged_user", "unprivileged_group"
20
+
21
+ # Help ensure your application will always spawn in the symlinked
22
+ # "current" directory that Capistrano sets up.
23
+ working_directory ENV['APP_ROOT'] # available in 0.94.0+
24
+
25
+ # listen on both a Unix domain socket and a TCP port,
26
+ # we use a shorter backlog for quicker failover when busy
27
+ listen ENV['UNICORN_SOCKET'], :backlog => 64
28
+
29
+ # nuke workers after 30 seconds instead of 60 seconds (the default)
30
+ timeout 30
31
+
32
+ # feel free to point this anywhere accessible on the filesystem
33
+ pid ENV['UNICORN_PID']
34
+
35
+ # By default, the Unicorn logger will write to stderr.
36
+ # Additionally, ome applications/frameworks log to stderr or stdout,
37
+ # so prevent them from going to /dev/null when daemonized here:
38
+ stderr_path "#{ENV['APP_ROOT']}/log/unicorn.stderr.log"
39
+ stdout_path "#{ENV['APP_ROOT']}/log/unicorn.stdout.log"
40
+
41
+ # combine Ruby 2.0.0dev or REE with "preload_app true" for memory savings
42
+ # http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
43
+ preload_app true
44
+ GC.respond_to?(:copy_on_write_friendly=) and
45
+ GC.copy_on_write_friendly = true
46
+
47
+ # Enable this flag to have unicorn test client connections by writing the
48
+ # beginning of the HTTP headers before calling the application. This
49
+ # prevents calling the application for connections that have disconnected
50
+ # while queued. This is only guaranteed to detect clients on the same
51
+ # host unicorn runs on, and unlikely to detect disconnects even on a
52
+ # fast LAN.
53
+ check_client_connection false
54
+
55
+ before_fork do |server, worker|
56
+ # the following is highly recomended for Rails + "preload_app true"
57
+ # as there's no need for the master process to hold a connection
58
+ defined?(ActiveRecord::Base) and
59
+ ActiveRecord::Base.connection.disconnect!
60
+
61
+ # The following is only recommended for memory/DB-constrained
62
+ # installations. It is not needed if your system can house
63
+ # twice as many worker_processes as you have configured.
64
+ #
65
+ # # This allows a new master process to incrementally
66
+ # # phase out the old master process with SIGTTOU to avoid a
67
+ # # thundering herd (especially in the "preload_app false" case)
68
+ # # when doing a transparent upgrade. The last worker spawned
69
+ # # will then kill off the old master process with a SIGQUIT.
70
+ old_pid = "#{server.config[:pid]}.oldbin"
71
+ if old_pid != server.pid
72
+ begin
73
+ sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
74
+ Process.kill(sig, File.read(old_pid).to_i)
75
+ rescue Errno::ENOENT, Errno::ESRCH
76
+ end
77
+ end
78
+ #
79
+ # Throttle the master from forking too quickly by sleeping. Due
80
+ # to the implementation of standard Unix signal handlers, this
81
+ # helps (but does not completely) prevent identical, repeated signals
82
+ # from being lost when the receiving process is busy.
83
+ # sleep 1
84
+ end
85
+
86
+ after_fork do |server, worker|
87
+ # per-process listener ports for debugging/admin/migrations
88
+ # addr = "127.0.0.1:#{9293 + worker.nr}"
89
+ # server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
90
+
91
+ # the following is *required* for Rails + "preload_app true",
92
+ defined?(ActiveRecord::Base) and
93
+ ActiveRecord::Base.establish_connection
94
+
95
+ # if preload_app is true, then you may also want to check and
96
+ # restart any other shared sockets/descriptors such as Memcached,
97
+ # and Redis. TokyoCabinet file handles are safe to reuse
98
+ # between any number of forked children (assuming your kernel
99
+ # correctly implements pread()/pwrite() system calls)
100
+ end
101
+
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-vmf
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sean Walberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: capistrano
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rvm1-capistrano3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Some capistrano automation to handle apps deployed to VMFarms
70
+ email:
71
+ - sean@ertw.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - capistrano-vmf.gemspec
82
+ - lib/capistrano/tasks/files.cap
83
+ - lib/capistrano/tasks/redis.cap
84
+ - lib/capistrano/tasks/vmf.cap
85
+ - lib/capistrano/vmf.rb
86
+ - lib/generators/vmf/newrelic_generator.rb
87
+ - lib/generators/vmf/unicorn_generator.rb
88
+ - templates/newrelic.yml.erb
89
+ - templates/unicorn.rb.erb
90
+ homepage: https://github.com/swalberg/capistrano-vmf
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.2.1
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Some capistrano automation to handle apps deployed to VMFarms
114
+ test_files: []