deploy_mate 0.17.6 → 0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/deploy-mate.gemspec +1 -1
- data/lib/capistrano/deploy_mate_capfile.rb +1 -1
- data/lib/capistrano/deploy_mate_defaults.rb +1 -3
- data/lib/capistrano/modules/shell.rb +20 -0
- data/lib/capistrano/tasks/bluepill.rake +18 -6
- data/lib/capistrano/tasks/logrotate.rake +5 -2
- data/lib/capistrano/tasks/machine.rake +17 -17
- data/lib/capistrano/tasks/nginx.rake +14 -9
- data/lib/capistrano/tasks/puma.rake +4 -1
- data/lib/capistrano/tasks/unicorn.rake +4 -1
- data/lib/capistrano/tasks/upstart.rake +10 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c02225815d07b37452f67f963f13d5b36acf51eb
|
4
|
+
data.tar.gz: 84991452955ddc3b8163cfd1a62448db3a5e37e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da23d19df9d514d86f887454443897411a99ebd2d0b0725c40d819996caaa64940169db8014021fe25c2d8d19006c6293c113c63500e387ec53e04da34276032
|
7
|
+
data.tar.gz: d2d1b78e33ada5b83284002b6b00970e05423f8268616aa0485420b21b92e6a4707071632be214b6c0b777fbdb6ec0ef05faa2317dd6c05ab98567e52d126ba9
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ This little gem can be added to your ruby-projects in order to **set up a workin
|
|
6
6
|
|
7
7
|
The resulting server will work with this setup:
|
8
8
|
- NGINX Webserver (http://nginx.org/)
|
9
|
-
- Unicorn Rack App Server (http://unicorn.bogomips.org/)
|
9
|
+
- Unicorn Rack App Server (http://unicorn.bogomips.org/) / Puma Rack App Server (http://puma.io/)
|
10
10
|
- Bluepill Process Monitoring (https://github.com/bluepill-rb/bluepill)
|
11
11
|
- RVM as user-install (http://rvm.io)
|
12
12
|
- [Optional] ImageMagick (http://www.imagemagick.org)
|
@@ -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
|
+
* **0.18 (2016-02-25)**: Added support for capistrano 3.4, Ask before overwriting existing config-files
|
32
33
|
* **2016-02-19**: Made selection of a deployed branch possible
|
33
34
|
* **2016-02-17**: Added support for puma as application server
|
34
35
|
* **2015-10-12**: Support additional linked-directories
|
data/deploy-mate.gemspec
CHANGED
@@ -23,7 +23,7 @@ require 'capistrano/bundler'
|
|
23
23
|
require "capistrano/helpers.rb"
|
24
24
|
|
25
25
|
# Load custom modules with helper functions
|
26
|
-
%w(aptitude bluepill upstart user_management).each do |m|
|
26
|
+
%w(aptitude bluepill upstart user_management shell).each do |m|
|
27
27
|
load File.expand_path("../modules/#{m}.rb", __FILE__)
|
28
28
|
end
|
29
29
|
|
@@ -25,9 +25,7 @@ set :app_server, "unicorn" # default to unicorn if nothing set
|
|
25
25
|
namespace :deploy do
|
26
26
|
desc 'Restart application'
|
27
27
|
task :restart do
|
28
|
-
|
29
|
-
invoke "bluepill:restart"
|
30
|
-
end
|
28
|
+
invoke "bluepill:restart"
|
31
29
|
end
|
32
30
|
|
33
31
|
desc 'Ensure that the app folder is present'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Shell
|
2
|
+
|
3
|
+
def file_exists?(file)
|
4
|
+
test("[ -f #{file} ]")
|
5
|
+
end
|
6
|
+
|
7
|
+
def overwrite_file?(file)
|
8
|
+
ask(:answer, "File #{file} already exists. Overwrite it? (y/N)")
|
9
|
+
fetch(:answer).downcase == "y"
|
10
|
+
end
|
11
|
+
|
12
|
+
def file_exists_and_overwrite?(file)
|
13
|
+
file_exists?(file) && overwrite_file?(file)
|
14
|
+
end
|
15
|
+
|
16
|
+
def file_new_or_overwrite?(file)
|
17
|
+
!file_exists?(file) || overwrite_file?(file)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -1,29 +1,42 @@
|
|
1
1
|
namespace :bluepill do
|
2
|
+
include Shell
|
2
3
|
|
3
4
|
desc "Installs the application pill"
|
4
5
|
task :setup do
|
5
6
|
on roles(:app) do
|
6
7
|
execute "mkdir -p #{shared_path}/config"
|
7
|
-
|
8
|
+
if file_new_or_overwrite?("#{shared_path}/config/#{fetch(:application)}.pill")
|
9
|
+
template "application.pill.erb", "#{shared_path}/config/#{fetch(:application)}.pill"
|
10
|
+
end
|
8
11
|
end
|
9
12
|
end
|
10
13
|
|
11
14
|
desc "Starts bluepill"
|
12
15
|
task :start do
|
13
16
|
on roles(:app) do
|
14
|
-
|
17
|
+
if !bluepill_running?
|
18
|
+
sudo "start bluepill"
|
19
|
+
else
|
20
|
+
info "No need to start bluepill, it is running!"
|
21
|
+
end
|
15
22
|
end
|
16
23
|
end
|
17
24
|
|
18
25
|
desc "Stops app server"
|
19
26
|
task :stop do
|
20
27
|
on roles(:app) do
|
21
|
-
|
28
|
+
if bluepill_running?
|
29
|
+
sudo "stop bluepill"
|
30
|
+
else
|
31
|
+
"Can't stop bluepill because it's not running!"
|
32
|
+
end
|
22
33
|
end
|
23
34
|
end
|
24
35
|
|
25
36
|
desc "Restarts/Reloads app gracefully"
|
26
37
|
task :restart do
|
38
|
+
invoke "bluepill:start"
|
39
|
+
|
27
40
|
on roles(:app) do
|
28
41
|
if bluepill_running?
|
29
42
|
if pill_running?(fetch(:app_server))
|
@@ -31,11 +44,10 @@ namespace :bluepill do
|
|
31
44
|
else
|
32
45
|
execute :rvmsudo, :bluepill, fetch(:application), :start
|
33
46
|
end
|
34
|
-
else
|
35
|
-
invoke "bluepill:start"
|
36
|
-
invoke "nginx:reload"
|
37
47
|
end
|
38
48
|
end
|
49
|
+
|
50
|
+
invoke "nginx:reload"
|
39
51
|
end
|
40
52
|
before :restart, 'rvm:hook'
|
41
53
|
end
|
@@ -1,10 +1,13 @@
|
|
1
1
|
namespace :logrotate do
|
2
|
+
include Shell
|
2
3
|
|
3
4
|
desc "Install the logrotate config"
|
4
5
|
task :setup do
|
5
6
|
on roles(:app) do
|
6
|
-
|
7
|
-
|
7
|
+
if file_new_or_overwrite?("/etc/logrotate.d/#{fetch(:application)}")
|
8
|
+
template "logrotate.erb", "/tmp/logrotate-#{fetch(:application)}"
|
9
|
+
sudo "mv /tmp/logrotate-#{fetch(:application)} /etc/logrotate.d/#{fetch(:application)}"
|
10
|
+
end
|
8
11
|
sudo "chown root:root /etc/logrotate.d/#{fetch(:application)}"
|
9
12
|
end
|
10
13
|
end
|
@@ -6,24 +6,24 @@ namespace :machine do
|
|
6
6
|
task :init do
|
7
7
|
on roles(:app) do
|
8
8
|
apt_get_update
|
9
|
-
invoke "machine:install:htop"
|
10
|
-
invoke "machine:install:language_pack_de"
|
11
|
-
invoke "machine:install:unattended_upgrades"
|
12
|
-
invoke "machine:install:ntp"
|
13
|
-
invoke "machine:install:git"
|
14
|
-
invoke "machine:install:nginx"
|
15
|
-
invoke "machine:install:fail2ban"
|
16
|
-
invoke "machine:install:rvm"
|
17
|
-
invoke "machine:install:ruby"
|
18
|
-
invoke "machine:install:set_defaults"
|
19
|
-
invoke "machine:install:bluepill"
|
20
|
-
invoke "machine:install:bundler"
|
21
|
-
invoke "machine:install:nodejs"
|
22
|
-
invoke "machine:install:elasticsearch"
|
23
|
-
invoke "machine:install:imagemagick" if fetch(:imagemagick)
|
24
|
-
invoke "machine:install:mysql_dev" if fetch(:db_engine) == "mysql"
|
25
|
-
invoke "machine:install:postgres_dev" if fetch(:db_engine) == "postgresql"
|
26
9
|
end
|
10
|
+
invoke "machine:install:htop"
|
11
|
+
invoke "machine:install:language_pack_de"
|
12
|
+
invoke "machine:install:unattended_upgrades"
|
13
|
+
invoke "machine:install:ntp"
|
14
|
+
invoke "machine:install:git"
|
15
|
+
invoke "machine:install:nginx"
|
16
|
+
invoke "machine:install:fail2ban"
|
17
|
+
invoke "machine:install:rvm"
|
18
|
+
invoke "machine:install:ruby"
|
19
|
+
invoke "machine:install:set_defaults"
|
20
|
+
invoke "machine:install:bluepill"
|
21
|
+
invoke "machine:install:bundler"
|
22
|
+
invoke "machine:install:nodejs"
|
23
|
+
invoke "machine:install:elasticsearch"
|
24
|
+
invoke "machine:install:imagemagick" if fetch(:imagemagick)
|
25
|
+
invoke "machine:install:mysql_dev" if fetch(:db_engine) == "mysql"
|
26
|
+
invoke "machine:install:postgres_dev" if fetch(:db_engine) == "postgresql"
|
27
27
|
end
|
28
28
|
before "machine:init", "machine:check_ubuntu_user"
|
29
29
|
before "deploy", "machine:check_ubuntu_user"
|
@@ -1,30 +1,35 @@
|
|
1
1
|
set_default(:nginx_server_name, "*.*")
|
2
2
|
|
3
3
|
namespace :nginx do
|
4
|
+
include Shell
|
4
5
|
|
5
6
|
desc "Installs the nginx configs"
|
6
7
|
task :setup do
|
7
8
|
on roles(:web) do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
if file_new_or_overwrite?("/etc/nginx/nginx.conf")
|
10
|
+
template "nginx_base.conf.erb", "/tmp/nginx_conf"
|
11
|
+
sudo "mv /tmp/nginx_conf /etc/nginx/nginx.conf"
|
12
|
+
end
|
13
|
+
|
14
|
+
if file_new_or_overwrite?("/etc/nginx/sites-available/#{fetch(:application)}.conf")
|
15
|
+
template "nginx_app.conf.erb", "/tmp/#{fetch(:application)}_conf"
|
16
|
+
sudo "mv /tmp/#{fetch(:application)}_conf /etc/nginx/sites-available/#{fetch(:application)}.conf"
|
17
|
+
end
|
12
18
|
|
13
|
-
if
|
19
|
+
if file_exists? "/etc/nginx/sites-enabled/default"
|
14
20
|
sudo "rm /etc/nginx/sites-enabled/default"
|
15
21
|
end
|
16
22
|
|
17
23
|
execute "mkdir -p #{shared_path}/log"
|
18
|
-
|
19
|
-
invoke "nginx:enable_site"
|
20
|
-
invoke "nginx:reload"
|
21
24
|
end
|
25
|
+
invoke "nginx:enable_site"
|
26
|
+
invoke "nginx:reload"
|
22
27
|
end
|
23
28
|
|
24
29
|
desc "Enable the app page for nginx"
|
25
30
|
task :enable_site do
|
26
31
|
on roles(:web) do
|
27
|
-
unless
|
32
|
+
unless file_exists? "/etc/nginx/sites-enabled/#{fetch(:application)}.conf"
|
28
33
|
sudo "ln -sf /etc/nginx/sites-available/#{fetch(:application)}.conf /etc/nginx/sites-enabled/#{fetch(:application)}.conf"
|
29
34
|
end
|
30
35
|
end
|
@@ -5,12 +5,15 @@ set_default(:puma_worker_grace_time, "60")
|
|
5
5
|
|
6
6
|
namespace :puma do
|
7
7
|
include Bluepill
|
8
|
+
include Shell
|
8
9
|
|
9
10
|
desc "Installs the puma config"
|
10
11
|
task :setup do
|
11
12
|
on roles(:app) do
|
12
13
|
execute "mkdir -p #{shared_path}/config"
|
13
|
-
|
14
|
+
if file_new_or_overwrite?("#{shared_path}/config/puma.rb")
|
15
|
+
template "puma.rb.erb", "#{shared_path}/config/puma.rb"
|
16
|
+
end
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
@@ -4,12 +4,15 @@ set_default(:unicorn_worker_grace_time, "60")
|
|
4
4
|
|
5
5
|
namespace :unicorn do
|
6
6
|
include Bluepill
|
7
|
+
include Shell
|
7
8
|
|
8
9
|
desc "Installs the unicorn config"
|
9
10
|
task :setup do
|
10
11
|
on roles(:app) do
|
11
12
|
execute "mkdir -p #{shared_path}/config"
|
12
|
-
|
13
|
+
if file_new_or_overwrite?("#{shared_path}/config/unicorn.rb")
|
14
|
+
template "unicorn.rb.erb", "#{shared_path}/config/unicorn.rb"
|
15
|
+
end
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
@@ -1,19 +1,25 @@
|
|
1
1
|
namespace :upstart do
|
2
2
|
include Upstart
|
3
|
+
include Shell
|
3
4
|
|
5
|
+
# TODO: remove one of these - they do the same
|
4
6
|
desc "Install the upstart config"
|
5
7
|
task :setup do
|
6
8
|
on roles(:app) do
|
7
|
-
|
8
|
-
|
9
|
+
if file_new_or_overwrite?("/etc/init/bluepill.conf")
|
10
|
+
template "upstart.conf.erb", "/tmp/bluepill.conf"
|
11
|
+
sudo "mv /tmp/bluepill.conf /etc/init/"
|
12
|
+
end
|
9
13
|
sudo "chown root:root /etc/init/bluepill.conf"
|
10
14
|
end
|
11
15
|
end
|
12
16
|
|
13
17
|
task :start do
|
14
18
|
on roles(:app) do
|
15
|
-
|
16
|
-
|
19
|
+
if file_new_or_overwrite?("/etc/init/bluepill.conf")
|
20
|
+
template "upstart.conf.erb", "/tmp/bluepill.conf"
|
21
|
+
sudo "mv /tmp/bluepill.conf /etc/init/"
|
22
|
+
end
|
17
23
|
sudo "chown root:root /etc/init/bluepill.conf"
|
18
24
|
end
|
19
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deploy_mate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.18'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Adler
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/capistrano/helpers.rb
|
97
97
|
- lib/capistrano/modules/aptitude.rb
|
98
98
|
- lib/capistrano/modules/bluepill.rb
|
99
|
+
- lib/capistrano/modules/shell.rb
|
99
100
|
- lib/capistrano/modules/upstart.rb
|
100
101
|
- lib/capistrano/modules/user_management.rb
|
101
102
|
- lib/capistrano/scripts/create_ubuntu_user.sh
|