deploy_mate 0.17.4 → 0.17.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +2 -1
- data/deploy-mate.gemspec +4 -4
- data/lib/capistrano/configs/application.pill.erb +21 -1
- data/lib/capistrano/configs/logrotate.erb +2 -2
- data/lib/capistrano/configs/nginx_app.conf.erb +3 -3
- data/lib/capistrano/configs/puma.rb.erb +55 -0
- data/lib/capistrano/deploy_mate_capfile.rb +1 -1
- data/lib/capistrano/deploy_mate_defaults.rb +3 -0
- data/lib/capistrano/tasks/bluepill.rake +2 -3
- data/lib/capistrano/tasks/machine.rake +2 -1
- data/lib/capistrano/tasks/puma.rake +17 -0
- data/lib/deploy_mate/tasks.rake +15 -14
- data/lib/deploy_mate/templates/deploy/stage.rb.erb +1 -1
- data/lib/deploy_mate/templates/deploy.rb.erb +2 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b32dbcc8129a7dec28bed595b73896b7d2640b3c
|
4
|
+
data.tar.gz: 6c01d173525aea2c48d9b688825c26a8628e4f4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2df75c00a46a75298cb3c03fb30433387ab7ffaea1c53c855f5eead2390ee0029f64b33ca3cfc67674dcb0dbd877319da6a719ed73e3e6515d86aea17f7a8da
|
7
|
+
data.tar.gz: 4b408d949d237aa3697d29c4c88aaec7d922795cf653a4da7a4c1dd588aef79807d5a3b10cba41ad6956ce444b474cc4b2b802ecc9096de74a41f111e0efe6e3
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.2.
|
1
|
+
ruby-2.2.3
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
This little gem can be added to your ruby-projects in order to **set up a working ruby-server** and **deploy** to it.
|
6
6
|
|
7
|
-
The resulting server will work with this setup:
|
7
|
+
The resulting server will work with this setup:
|
8
8
|
- NGINX Webserver (http://nginx.org/)
|
9
9
|
- Unicorn Rack App Server (http://unicorn.bogomips.org/)
|
10
10
|
- Bluepill Process Monitoring (https://github.com/bluepill-rb/bluepill)
|
@@ -29,6 +29,7 @@ It uses the following Capistrano-roles to divide the installed components:
|
|
29
29
|
- **cronjobs**: [OPTIONAL] For environments where `whenever` should manage/run cronjobs
|
30
30
|
|
31
31
|
## Changelog
|
32
|
+
* **2015-10-17**: Added support for puma as application server
|
32
33
|
* **2015-10-12**: Support additional linked-directories
|
33
34
|
* **2015-08-27**: Small fix for `nginx`-config regarding gzipping of svgs
|
34
35
|
* **2015-08-14**: Important small fix for `nginx`-config regarding ssl
|
data/deploy-mate.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "deploy_mate"
|
3
|
-
s.version = "0.17.
|
3
|
+
s.version = "0.17.5"
|
4
4
|
|
5
|
-
s.authors = ["Tim Adler"]
|
6
|
-
s.date = %q{
|
5
|
+
s.authors = ["Tim Adler", "Marcus Geißler"]
|
6
|
+
s.date = %q{2016-02-17}
|
7
7
|
s.description = %q{This is how we deploy around here.}
|
8
8
|
s.summary = s.description
|
9
|
-
s.email = %q{
|
9
|
+
s.email = %q{development (at) hanseventures (dot) com}
|
10
10
|
s.license = "MIT"
|
11
11
|
|
12
12
|
s.files = `git ls-files`.split("\n")
|
@@ -7,6 +7,25 @@ Bluepill.application("<%= fetch(:application) %>", :log_file => "#{shared_path}/
|
|
7
7
|
app.uid = 'ubuntu'
|
8
8
|
app.gid = 'www-data'
|
9
9
|
|
10
|
+
<% if fetch(:app_server) == "puma" %>
|
11
|
+
app.process("puma") do |process|
|
12
|
+
process.pid_file = "#{shared_path}/system/pids/puma.pid"
|
13
|
+
process.environment = { 'BUNDLE_GEMFILE' => "#{current_path}/Gemfile" }
|
14
|
+
|
15
|
+
process.start_command = "/home/ubuntu/.rvm/wrappers/default/bundle exec puma -C #{shared_path}/config/puma.rb #{current_path}/config.ru"
|
16
|
+
process.stop_command = "kill -QUIT {{PID}}"
|
17
|
+
process.restart_command = "kill -USR2 {{PID}}"
|
18
|
+
|
19
|
+
process.start_grace_time = 10.seconds
|
20
|
+
process.stop_grace_time = 10.seconds
|
21
|
+
process.restart_grace_time = 10.seconds
|
22
|
+
|
23
|
+
process.monitor_children do |child_process|
|
24
|
+
child_process.stop_command = "kill -9 {{PID}}"
|
25
|
+
child_process.checks :mem_usage, :every => 30.seconds, :below => 500.megabytes, :times => [3,4], :fires => :stop
|
26
|
+
end
|
27
|
+
end
|
28
|
+
<% else %>
|
10
29
|
app.process("unicorn") do |process|
|
11
30
|
process.pid_file = "#{shared_path}/system/pids/unicorn.pid"
|
12
31
|
process.environment = { 'BUNDLE_GEMFILE' => "#{current_path}/Gemfile" }
|
@@ -24,6 +43,7 @@ Bluepill.application("<%= fetch(:application) %>", :log_file => "#{shared_path}/
|
|
24
43
|
child_process.checks :mem_usage, :every => 30.seconds, :below => 500.megabytes, :times => [3,4], :fires => :stop
|
25
44
|
end
|
26
45
|
end
|
46
|
+
<% end %>
|
27
47
|
|
28
48
|
<% if fetch(:sidekiq) %>
|
29
49
|
app.process("sidekiq") do |process|
|
@@ -36,4 +56,4 @@ Bluepill.application("<%= fetch(:application) %>", :log_file => "#{shared_path}/
|
|
36
56
|
end
|
37
57
|
<% end %>
|
38
58
|
|
39
|
-
end
|
59
|
+
end
|
@@ -17,6 +17,6 @@
|
|
17
17
|
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
|
18
18
|
endscript
|
19
19
|
lastaction
|
20
|
-
[ ! -f <%= shared_path %>/system/pids
|
20
|
+
[ ! -f <%= shared_path %>/system/pids/<%= fetch(:app_server) %>.pid ] || kill -USR1 `cat <%= shared_path %>/system/pids/<%= fetch(:app_server) %>.pid`
|
21
21
|
endscript
|
22
|
-
}
|
22
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
upstream
|
2
|
-
server unix:<%= shared_path %>/system/sockets
|
1
|
+
upstream appserver_upstream {
|
2
|
+
server unix:<%= shared_path %>/system/sockets/<%= fetch(:app_server) %>.sock;
|
3
3
|
}
|
4
4
|
|
5
5
|
server {
|
@@ -21,7 +21,7 @@ server {
|
|
21
21
|
proxy_set_header Host $http_host;
|
22
22
|
proxy_redirect off;
|
23
23
|
|
24
|
-
proxy_pass http://
|
24
|
+
proxy_pass http://appserver_upstream;
|
25
25
|
break;
|
26
26
|
}
|
27
27
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# puma configuration
|
2
|
+
|
3
|
+
shared_path = "<%= shared_path %>"
|
4
|
+
|
5
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
6
|
+
# The `threads` method setting takes two numbers a minimum and maximum.
|
7
|
+
# Any libraries that use thread pools should be configured to match
|
8
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
9
|
+
# and maximum, this matches the default thread size of Active Record.
|
10
|
+
#
|
11
|
+
threads_count = <%= fetch(:puma_threads) %>
|
12
|
+
threads threads_count, threads_count
|
13
|
+
|
14
|
+
# Specifies the `environment` that Puma will run in.
|
15
|
+
#
|
16
|
+
environment "<%= fetch(:environment) %>"
|
17
|
+
|
18
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
19
|
+
# Workers are forked webserver processes. If using threads and workers together
|
20
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
21
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
22
|
+
# processes).
|
23
|
+
#
|
24
|
+
workers <%= fetch(:puma_workers) %>
|
25
|
+
|
26
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
27
|
+
# This directive tells Puma to first boot the application and load code
|
28
|
+
# before forking the application. This takes advantage of Copy On Write
|
29
|
+
# process behavior so workers use less memory. If you use this option
|
30
|
+
# you need to make sure to reconnect any threads in the `on_worker_boot`
|
31
|
+
# block.
|
32
|
+
#
|
33
|
+
preload_app!
|
34
|
+
|
35
|
+
# The code in the `on_worker_boot` will be called if you are using
|
36
|
+
# clustered mode by specifying a number of `workers`. After each worker
|
37
|
+
# process is booted this block will be run, if you are using `preload_app!`
|
38
|
+
# option you will want to use this block to reconnect to any threads
|
39
|
+
# or connections that may have been created at application boot, Ruby
|
40
|
+
# cannot share connections between processes.
|
41
|
+
#
|
42
|
+
on_worker_boot do
|
43
|
+
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Set up socket location
|
47
|
+
bind "unix://#{shared_path}/system/sockets/puma.sock"
|
48
|
+
|
49
|
+
# Logging
|
50
|
+
stdout_redirect "#{shared_path}/log/puma.stdout.log", "#{shared_path}/log/puma.stderr.log", true
|
51
|
+
|
52
|
+
# Set master PID and state locations
|
53
|
+
pidfile "#{shared_path}/system/pids/puma.pid"
|
54
|
+
state_path "#{shared_path}/system/pids/puma.state"
|
55
|
+
activate_control_app
|
@@ -28,6 +28,6 @@ require "capistrano/helpers.rb"
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
|
31
|
-
%w(bluepill logrotate machine elasticsearch nginx rvm unicorn upstart).each do |t|
|
31
|
+
%w(bluepill logrotate machine elasticsearch nginx rvm unicorn puma upstart).each do |t|
|
32
32
|
import File.expand_path("../tasks/#{t}.rake", __FILE__)
|
33
33
|
end
|
@@ -19,6 +19,9 @@ set :bundle_flags, "--deployment"
|
|
19
19
|
set :bundle_without, %w{development test}.join(' ')
|
20
20
|
set :bundle_exec, "bundle exec"
|
21
21
|
|
22
|
+
# app server
|
23
|
+
set :app_server, "unicorn" # default to unicorn if nothing set
|
24
|
+
|
22
25
|
namespace :deploy do
|
23
26
|
desc 'Restart application'
|
24
27
|
task :restart do
|
@@ -15,7 +15,7 @@ namespace :bluepill do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
desc "Stops
|
18
|
+
desc "Stops app server"
|
19
19
|
task :stop do
|
20
20
|
on roles(:app) do
|
21
21
|
sudo "stop bluepill"
|
@@ -26,7 +26,7 @@ namespace :bluepill do
|
|
26
26
|
task :restart do
|
27
27
|
on roles(:app) do
|
28
28
|
if bluepill_running?
|
29
|
-
if pill_running?(:
|
29
|
+
if pill_running?(fetch(:app_server))
|
30
30
|
execute :rvmsudo, :bluepill, fetch(:application), :restart
|
31
31
|
else
|
32
32
|
execute :rvmsudo, :bluepill, fetch(:application), :start
|
@@ -39,4 +39,3 @@ namespace :bluepill do
|
|
39
39
|
end
|
40
40
|
before :restart, 'rvm:hook'
|
41
41
|
end
|
42
|
-
|
@@ -49,7 +49,8 @@ namespace :machine do
|
|
49
49
|
desc "Install configs"
|
50
50
|
task :setup do
|
51
51
|
invoke "nginx:setup"
|
52
|
-
invoke "unicorn:setup"
|
52
|
+
invoke "unicorn:setup" if fetch(:app_server) == "unicorn"
|
53
|
+
invoke "puma:setup" if fetch(:app_server) == "puma"
|
53
54
|
invoke "upstart:setup"
|
54
55
|
invoke "logrotate:setup"
|
55
56
|
invoke "bluepill:setup"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
set_default(:puma_workers, "5")
|
2
|
+
set_default(:puma_threads, "10")
|
3
|
+
set_default(:puma_timeout, "30")
|
4
|
+
set_default(:puma_worker_grace_time, "60")
|
5
|
+
|
6
|
+
namespace :puma do
|
7
|
+
include Bluepill
|
8
|
+
|
9
|
+
desc "Installs the puma config"
|
10
|
+
task :setup do
|
11
|
+
on roles(:app) do
|
12
|
+
execute "mkdir -p #{shared_path}/config"
|
13
|
+
template "puma.rb.erb", "#{shared_path}/config/puma.rb"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/lib/deploy_mate/tasks.rake
CHANGED
@@ -7,19 +7,20 @@ namespace :deploy_mate do
|
|
7
7
|
puts "I'm your DEPLOY_MATE."
|
8
8
|
puts "We will setting up your deployment now."
|
9
9
|
|
10
|
-
@app_name = ask("[01/
|
11
|
-
@stage_name = ask("[02/
|
12
|
-
@ssh_name = ask("[03/
|
13
|
-
@ruby_version = ask("[04/
|
14
|
-
@db_engine = ask_until("[05/
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
10
|
+
@app_name = ask("[01/14] App-Name (for nginx, servers, etc.)", guess_app_name)
|
11
|
+
@stage_name = ask("[02/14] Give the first stage a name", "prestage")
|
12
|
+
@ssh_name = ask("[03/14] SSH-Hostname for the server", "#{@app_name}-#{@stage_name}")
|
13
|
+
@ruby_version = ask("[04/14] Ruby-Version (the RVM-way, e.g. ruby-2.2.0)", guess_ruby_version)
|
14
|
+
@db_engine = ask_until("[05/14] What db are you using?", %w( postgresql mysql ), "mysql")
|
15
|
+
@app_server = ask_until("[06/14] What app server do you want to use?", %w( unicorn puma ), "unicorn")
|
16
|
+
@repo_url = ask("[07/14] Url-Location of git-repo", "git@github.com:hanseventures/#{@app_name}.git")
|
17
|
+
@is_rails = yes_or_no?("[08/14] Is this a RAILS project ?", (rails_present? ? "yes" : "no"))
|
18
|
+
@needs_imagemagick = yes_or_no?("[09/14] Does this project need ImageMagick ?", (needs_imagemagick? ? "yes" : "no"))
|
19
|
+
@uses_sidekiq = yes_or_no?("[10/14] Does this project use Sidekiq ?", (uses_sidekiq? ? "yes" : "no"))
|
20
|
+
@branch_name = ask("[11/14] Branch to deploy '#{@stage_name}' from", "dev")
|
21
|
+
@host_name = ask("[12/14] Web-URL for '#{@stage_name}'", "#{@stage_name}.#{@app_name}")
|
22
|
+
@environment = ask("[13/14] #{@stage_name}'s environment (RACK_ENV/RAILS_ENV)", "#{@stage_name}")
|
23
|
+
@needs_elasticsearch = yes_or_no?("[14/14] Do you need ElasticSearch on this machine ?", "no")
|
23
24
|
|
24
25
|
puts "Aye!"
|
25
26
|
puts "Worrrrking..."
|
@@ -106,4 +107,4 @@ end
|
|
106
107
|
|
107
108
|
def cat_file(filename)
|
108
109
|
File.open(filename, 'rb') { |f| f.read } if File.exist?(filename)
|
109
|
-
end
|
110
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
server "<%= @ssh_name %>", roles: [:app, :web<% if @needs_elasticsearch %>, :search<%end %>], :primary => true
|
1
|
+
server "<%= @ssh_name %>", roles: [:app, :db, :web<% if @needs_elasticsearch %>, :search<% end %>], :primary => true
|
2
2
|
|
3
3
|
set :unicorn_workers, "2"
|
4
4
|
set :nginx_server_name, "<%= @host_name %>"
|
@@ -10,6 +10,7 @@ set :stages, %w(<%= @stage_name %>)
|
|
10
10
|
set :default_stage, '<%= @stage_name %>'
|
11
11
|
set :repo_url, '<%= @repo_url %>'
|
12
12
|
set :db_engine, '<%= @db_engine %>'
|
13
|
+
set :app_server, '<%= @app_server %>'
|
13
14
|
|
14
15
|
set :imagemagick, <%= @needs_imagemagick %>
|
15
16
|
set :sidekiq, <%= @uses_sidekiq %>
|
@@ -20,4 +21,4 @@ set :sidekiq, <%= @uses_sidekiq %>
|
|
20
21
|
# set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" }
|
21
22
|
# set :whenever_environment, fetch(:stage)
|
22
23
|
# set :whenever_roles, [:cronjobs]
|
23
|
-
# before "whenever:update_crontab", 'rvm:hook'
|
24
|
+
# before "whenever:update_crontab", 'rvm:hook'
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deploy_mate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Adler
|
8
|
+
- Marcus Geißler
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: capistrano
|
@@ -67,7 +68,7 @@ dependencies:
|
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: '0'
|
69
70
|
description: This is how we deploy around here.
|
70
|
-
email:
|
71
|
+
email: development (at) hanseventures (dot) com
|
71
72
|
executables: []
|
72
73
|
extensions: []
|
73
74
|
extra_rdoc_files: []
|
@@ -86,6 +87,7 @@ files:
|
|
86
87
|
- lib/capistrano/configs/logrotate.erb
|
87
88
|
- lib/capistrano/configs/nginx_app.conf.erb
|
88
89
|
- lib/capistrano/configs/nginx_base.conf.erb
|
90
|
+
- lib/capistrano/configs/puma.rb.erb
|
89
91
|
- lib/capistrano/configs/unicorn.rb.erb
|
90
92
|
- lib/capistrano/configs/upstart.conf.erb
|
91
93
|
- lib/capistrano/deploy_mate_capfile.rb
|
@@ -104,6 +106,7 @@ files:
|
|
104
106
|
- lib/capistrano/tasks/logrotate.rake
|
105
107
|
- lib/capistrano/tasks/machine.rake
|
106
108
|
- lib/capistrano/tasks/nginx.rake
|
109
|
+
- lib/capistrano/tasks/puma.rake
|
107
110
|
- lib/capistrano/tasks/rvm.rake
|
108
111
|
- lib/capistrano/tasks/seeds.rake
|
109
112
|
- lib/capistrano/tasks/unicorn.rake
|
@@ -132,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
135
|
version: '0'
|
133
136
|
requirements: []
|
134
137
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.4.
|
138
|
+
rubygems_version: 2.4.5.1
|
136
139
|
signing_key:
|
137
140
|
specification_version: 4
|
138
141
|
summary: This is how we deploy around here.
|