capistrano-generals 0.0.2 → 0.0.3

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: fdebc6315f89ed9b6e0c9a4a4d14e7e73a3e6244
4
- data.tar.gz: 5d313806553a1fc320e9a1eb46db7c6e627d4830
3
+ metadata.gz: d136e725fcb93bd1cc091d07d57fd41e18827bbd
4
+ data.tar.gz: d42a6257cb5b87d3e04349f2374de5e5da498d03
5
5
  SHA512:
6
- metadata.gz: 7502b3c0524e108402761ba462da56afc8510a61013e790f7c766543c1a28141bf61b91c6762c24bcae983a8b8d77865271444b0ccd8ec5886d1e9c5ea8367d9
7
- data.tar.gz: 9410356ba56ad748d5444695a12573b313ebe1a81836e57d535112290397f15d66dac42038ff71d3dc7e37fa62a1bf433812d5f5884bf40dccad6963210817b1
6
+ metadata.gz: 4b018c2ee47f23b398c1a4ab91d484008efd12ab0faedc745ba73e705e5558eccac5fc1488665d734f13314dece33c53d599f7b744bd48d239991402c5687a4a
7
+ data.tar.gz: a7967de06065b57dc86d1f4c23a8ad8344611f5dac8a78bd4469a2b2b549ca3a5752498b3dc0d6895a43025bdf221e170d7cdccdea024d3581220b6fc95c6da8
@@ -5,7 +5,33 @@ module Capistrano
5
5
  "\033[31m#{text}\033[0m"
6
6
  end
7
7
 
8
- def get_config_file config, stage
8
+ # Try to find stage specific file, otherwice select default
9
+ # If the default does not exists, abort
10
+ def get_config_file(file_name, stage)
11
+ # Default local_file_name is stage specific.
12
+ local_file_name = get_config_file_name(file_name, stage)
13
+
14
+ # Check if file exists, else select default file
15
+ # If default file does not exists abort.
16
+ unless file_exists? local_file_name
17
+ unless file_exists? file_name
18
+ abort red "Cannot find file #{local_file_name} or #{file_name} on machine"
19
+ end
20
+ # The default file does exists, selecting that one
21
+ warn "Cannot find stage specific config file #{local_file_name} on machine, taking default #{file_name}"
22
+ local_file_name = file_name
23
+ end
24
+ local_file_name
25
+ end
26
+
27
+ # Returns if the file exists
28
+ # The default File.exists? does not work on a remote
29
+ def file_exists?(file_name)
30
+ test("[ -f #{file_name} ]")
31
+ end
32
+
33
+ # Get the stage specific name of the file
34
+ def get_config_file_name(config, stage)
9
35
  path = File.dirname(config)
10
36
  extension = File.extname(config)
11
37
  filename = File.basename(config, extension)
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Generals
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -0,0 +1,11 @@
1
+ namespace :deploy do
2
+
3
+ desc 'Restart nginx and unicorn.'
4
+ task :restart do
5
+ on roles(:app) do
6
+ execute "sudo /etc/init.d/unicorn_#{fetch(:application)}_#{fetch(:stage)} upgrade"
7
+ execute "sudo /etc/init.d/nginx restart"
8
+ end
9
+ end
10
+
11
+ end
@@ -12,26 +12,16 @@ namespace :deploy do
12
12
  # Loop through all linked files
13
13
  fetch(:linked_files).each do |file_name|
14
14
 
15
- # Default local_file_name is stage specific.
16
- local_file_name = get_config_file(file_name, fetch(:stage).to_s)
17
-
18
15
  # Initialize variable outsize run_locally block to make sure it can be
19
16
  # passed into the remote block
20
17
  local_cksum = nil
18
+ local_file_name = ''
21
19
 
22
20
  # Get file information
23
21
  run_locally do
24
22
 
25
- # Check if file exists, else select default file
26
- # If default file does not exists abort.
27
- unless File.exists? local_file_name
28
- unless File.exists? file_name
29
- abort red "Cannot find file #{local_file_name} or #{file_name} on local machine"
30
- end
31
- # The default file does exists, selecting that one
32
- warn "Cannot find stage specific config file #{local_file_name} on local machine, taking default #{file_name}"
33
- local_file_name = file_name
34
- end
23
+ # Try to find stage specific file, otherwice select default
24
+ local_file_name = get_config_file(file_name, fetch(:stage).to_s)
35
25
 
36
26
  # Get local file info
37
27
  local_cksum = capture :cksum, local_file_name
@@ -17,7 +17,7 @@ namespace :git do
17
17
 
18
18
  # Push selected branch to github
19
19
  unless system "git push #{repo_url} #{fetch(:branch)} #{'-f' if ENV['FORCE']}"
20
- abort red "Failed to push changes to #{fetch(:repo_url)} (set FORCE=true to force push to github)"
20
+ abort red "Failed to push changes to #{fetch(:repo_url)} (set FORCE=true to force push)"
21
21
  end
22
22
  end
23
23
  end
@@ -2,11 +2,18 @@ namespace :setup do
2
2
 
3
3
  desc "Symlinks config files for Nginx and Unicorn"
4
4
  task :symlink_nginx_and_unicorn do
5
- on roles(:app) do
6
- execute "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{fetch(:application)}"
7
- execute "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{fetch(:application)}"
5
+ on roles :app do
6
+ # Find stage specific config file
7
+ file_name = File.join current_path, 'config/nginx.conf'
8
+ file_name = get_config_file(file_name, fetch(:stage).to_s)
9
+ execute "ln -nfs #{file_name} /etc/nginx/sites-enabled/#{fetch(:application)}_#{fetch(:stage)}"
10
+
11
+ # Find stage specific config file
12
+ file_name = File.join current_path, 'config/unicorn_init.sh'
13
+ file_name = get_config_file(file_name, fetch(:stage).to_s)
14
+ execute "ln -nfs #{file_name} /etc/init.d/unicorn_#{fetch(:application)}_#{fetch(:stage)}"
8
15
  # Start unicorn at startup
9
- execute "sudo update-rc.d unicorn_#{fetch(:application)} defaults"
16
+ execute "sudo update-rc.d unicorn_#{fetch(:application)}_#{fetch(:stage)} defaults"
10
17
  end
11
18
  end
12
19
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-generals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stef Schenkelaars
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2015-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -69,6 +69,7 @@ files:
69
69
  - lib/capistrano/generals.rb
70
70
  - lib/capistrano/generals/helpers.rb
71
71
  - lib/capistrano/generals/version.rb
72
+ - lib/capistrano/tasks/deploy/restarts.rake
72
73
  - lib/capistrano/tasks/deploy/symlink.rake
73
74
  - lib/capistrano/tasks/git.rake
74
75
  - lib/capistrano/tasks/setup.rake
@@ -92,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
93
  version: '0'
93
94
  requirements: []
94
95
  rubyforge_project:
95
- rubygems_version: 2.2.2
96
+ rubygems_version: 2.4.5
96
97
  signing_key:
97
98
  specification_version: 4
98
99
  summary: Some general capistrano tasks which are commonly used