capistrano-generals 0.0.3 → 0.0.4

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: d136e725fcb93bd1cc091d07d57fd41e18827bbd
4
- data.tar.gz: d42a6257cb5b87d3e04349f2374de5e5da498d03
3
+ metadata.gz: ce3252d284b37a5a53addd7588452febc7463f92
4
+ data.tar.gz: 6c2250f553972533c6bb7a7612a798587c941541
5
5
  SHA512:
6
- metadata.gz: 4b018c2ee47f23b398c1a4ab91d484008efd12ab0faedc745ba73e705e5558eccac5fc1488665d734f13314dece33c53d599f7b744bd48d239991402c5687a4a
7
- data.tar.gz: a7967de06065b57dc86d1f4c23a8ad8344611f5dac8a78bd4469a2b2b549ca3a5752498b3dc0d6895a43025bdf221e170d7cdccdea024d3581220b6fc95c6da8
6
+ metadata.gz: 3ccf20f6e534a1a3d381f9a13c0780efdb0462be7b2352bc944ea34e10f3b5cc21f3f9900dcf85cb508120b6344c2711a1ebebe9e8498e73005f847cdd95c514
7
+ data.tar.gz: 17d2272ae37d8116479f558fefa17e7116a56b1d4724dd2fd2b175f9602cacf0d80733aa68519e04400b5d0d9d5ee602f6b1d067a82a92cfb6f57552a86093ec
data/README.md CHANGED
@@ -9,8 +9,8 @@ Add this to your application's `Gemfile`:
9
9
 
10
10
  ```ruby
11
11
  group :development do
12
- gem 'capistrano', '~> 3.2.1'
13
- gem 'capistrano-unicorn-nginx', '~> 3.1.0'
12
+ gem 'capistrano'
13
+ gem 'capistrano-generals'
14
14
  end
15
15
  ```
16
16
 
@@ -30,11 +30,32 @@ In your `config/deploy.rb` you can add the taks by adding them to the deploy nam
30
30
 
31
31
  ```ruby
32
32
  namespace :deploy do
33
- before :deploy, 'git:push'
34
- before :deploy, 'deploy:symlink:upload_linked_files'
33
+ before :deploy, 'git:push'
34
+ before :deploy, 'deploy:symlink:upload_linked_files'
35
+ after :deploy, 'setup:symlink:unicorn'
36
+ after :deploy, 'setup:symlink:nginx'
37
+ after :deploy, 'setup:symlink:sidekiq'
38
+ after :deploy, 'unicorn:restart'
39
+ after :rollback, 'unicorn:restart'
40
+ after :deploy, 'nginx:restart'
41
+ after :rollback, 'nginx:restart'
42
+ after :deploy, 'sidekiq:restart'
43
+ after :rollback, 'sidekiq:restart'
35
44
  end
36
45
  ```
37
46
 
47
+ ### Setup linked files
48
+ There are some tasks for linking configuration files to the system. It is
49
+ possible to use stage specific files like `config/nginx.staging.conf`. It will
50
+ then link this file to the system. If the stage specific file is not present,
51
+ it will look for the `config/nginx.conf` file. If that is absent as well it will
52
+ raise an error.
53
+ ```ruby
54
+ cap <stage> setup:symlink:nginx # Adds config/nginx.stage.conf to enabled nginx sites
55
+ cap <stage> setup:symlink:unicorn # Adds config/unicorn_init.stage.sh to /etc/init.d scripts and add run at startup
56
+ cap <stage> setup:symlink:sidekiq # Adds config/sidekiq_init.stag.sh to /etc/init.d scipts and add run at startup
57
+ ```
58
+
38
59
  ### Git push
39
60
  This first checks if there are no local changes that has not been committed.
40
61
  If all changes are committed, they are pushed.
@@ -50,6 +71,8 @@ example you want to upload `database.yml` to the `staging` environment,
50
71
  the system first searches for `database.staging.yml` and if it cannot find that
51
72
  it will fall back to the original.
52
73
 
74
+ ### Restart
75
+ This will upgrade the unicorn workers and restart nginx.
53
76
 
54
77
  ## Contributing
55
78
 
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Generals
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -0,0 +1,25 @@
1
+ namespace :nginx do
2
+
3
+ desc 'Start nginx'
4
+ task :start do
5
+ on roles(:app) do
6
+ execute 'sudo /etc/init.d/nginx start'
7
+ end
8
+ end
9
+
10
+ desc 'Stop nginx'
11
+ task :stop do
12
+ on roles(:app) do
13
+ execute 'sudo /etc/init.d/nginx stop'
14
+ sleep 3
15
+ end
16
+ end
17
+
18
+ desc 'Restart nginx'
19
+ task :restart do
20
+ on roles(:app) do
21
+ execute 'sudo /etc/init.d/nginx restart'
22
+ end
23
+ end
24
+
25
+ end
@@ -1,20 +1,41 @@
1
1
  namespace :setup do
2
2
 
3
- desc "Symlinks config files for Nginx and Unicorn"
4
- task :symlink_nginx_and_unicorn do
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)}"
3
+ namespace :symlink do
10
4
 
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)}"
15
- # Start unicorn at startup
16
- execute "sudo update-rc.d unicorn_#{fetch(:application)}_#{fetch(:stage)} defaults"
5
+ desc 'Symlink config file for nginx'
6
+ task :nginx do
7
+ on roles :app do
8
+ # Find stage specific config file
9
+ file_name = File.join current_path, 'config/nginx.conf'
10
+ file_name = get_config_file(file_name, fetch(:stage).to_s)
11
+ execute "ln -nfs #{file_name} /etc/nginx/sites-enabled/#{fetch(:application)}_#{fetch(:stage)}"
12
+ end
17
13
  end
14
+
15
+ desc 'Symlink config file for unicorn'
16
+ task :unicorn do
17
+ on roles :app do
18
+ # Find stage specific config file
19
+ file_name = File.join current_path, 'config/unicorn_init.sh'
20
+ file_name = get_config_file(file_name, fetch(:stage).to_s)
21
+ execute "ln -nfs #{file_name} /etc/init.d/unicorn_#{fetch(:application)}_#{fetch(:stage)}"
22
+ # Start unicorn at startup
23
+ execute "sudo update-rc.d unicorn_#{fetch(:application)}_#{fetch(:stage)} defaults"
24
+ end
25
+ end
26
+
27
+ desc 'Symlink config file for sidekiq'
28
+ task :sidekiq do
29
+ on roles :app do
30
+ # Find stage specific config file
31
+ file_name = File.join current_path, 'config/sidekiq_init.sh'
32
+ file_name = get_config_file(file_name, fetch(:stage).to_s)
33
+ execute "ln -nfs #{file_name} /etc/init.d/sidekiq_#{fetch(:application)}_#{fetch(:stage)}"
34
+ # Start unicorn at startup
35
+ execute "sudo update-rc.d sidekiq_#{fetch(:application)}_#{fetch(:stage)} defaults"
36
+ end
37
+ end
38
+
18
39
  end
19
40
 
20
41
  end
@@ -0,0 +1,24 @@
1
+ namespace :sidekiq do
2
+
3
+ desc 'Start sidekiq'
4
+ task :start do
5
+ on roles(:app) do
6
+ execute "sudo /etc/init.d/sidekiq_#{fetch(:application)}_#{fetch(:stage)} start"
7
+ end
8
+ end
9
+
10
+ desc 'Stop sidekiq'
11
+ task :stop do
12
+ on roles(:app) do
13
+ execute "sudo /etc/init.d/sidekiq_#{fetch(:application)}_#{fetch(:stage)} stop"
14
+ sleep 8
15
+ end
16
+ end
17
+
18
+ desc 'Restart sidekiq'
19
+ task :restart do
20
+ invoke 'sidekiq:stop'
21
+ invoke 'sidekiq:start'
22
+ end
23
+
24
+ end
@@ -0,0 +1,24 @@
1
+ namespace :unicorn do
2
+
3
+ desc 'Start unicorn'
4
+ task :start do
5
+ on roles(:app) do
6
+ execute "sudo /etc/init.d/unicorn_#{fetch(:application)}_#{fetch(:stage)} start"
7
+ end
8
+ end
9
+
10
+ desc 'Stop unicorn'
11
+ task :stop do
12
+ on roles(:app) do
13
+ execute "sudo /etc/init.d/unicorn_#{fetch(:application)}_#{fetch(:stage)} stop"
14
+ sleep 3
15
+ end
16
+ end
17
+
18
+ desc 'Restart unicorn'
19
+ task :restart do
20
+ invoke 'unicorn:stop'
21
+ invoke 'unicorn:start'
22
+ end
23
+
24
+ end
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stef Schenkelaars
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-02 00:00:00.000000000 Z
11
+ date: 2015-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -69,10 +69,12 @@ 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
73
72
  - lib/capistrano/tasks/deploy/symlink.rake
74
73
  - lib/capistrano/tasks/git.rake
74
+ - lib/capistrano/tasks/nginx.rake
75
75
  - lib/capistrano/tasks/setup.rake
76
+ - lib/capistrano/tasks/sidekiq.rake
77
+ - lib/capistrano/tasks/unicorn.rake
76
78
  homepage: ''
77
79
  licenses:
78
80
  - MIT
@@ -93,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
95
  version: '0'
94
96
  requirements: []
95
97
  rubyforge_project:
96
- rubygems_version: 2.4.5
98
+ rubygems_version: 2.4.6
97
99
  signing_key:
98
100
  specification_version: 4
99
101
  summary: Some general capistrano tasks which are commonly used
@@ -1,11 +0,0 @@
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