capistrano-devops 0.0.11 → 0.0.12

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: 5f659cb8b773117082d780ae806d1ed1b947bfcc
4
- data.tar.gz: 0cc552a88743023d4129be67b4de5c2a51db5a7d
3
+ metadata.gz: dfc29117069157ffb1037420ffca03faf6a9c2be
4
+ data.tar.gz: c3bf2166efb877a9effe7f85a4161bfd8c138796
5
5
  SHA512:
6
- metadata.gz: b1fa0fec94de41b4ad0d395c0efa74a6ad2cc5895d1f832c5e21e94017541bb58bd6dd04dd4cdac63ba44d9dff49950ec092524bf812aaed601a59740c83c672
7
- data.tar.gz: f272080f7b3653507dddfbdeb8c42bc79a961186461a912eec81209ef6542bdacb7249effe58436f620edd52bb589ec95e48f4ec771b7f3d270bcd0277327345
6
+ metadata.gz: f5ceec8875da0cf59e3a904e4a21c2bf1927ec28a5607a21d574dac5372c5560f8401c482884066561a8c1338e252c38e34cc0473884d20f7d84cb95d64b8e81
7
+ data.tar.gz: fc6dfb5812cc3960a7ee64c4df8a681cb463801e1e683706f8dc7d9c136cb4735290b2521d8b0d4a6c87d64005f2688feee425b0e8982ebe4b351d38ffcf8833
data/.gitignore CHANGED
@@ -15,4 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- *.vagrant
18
+ *.vagrant
19
+ .idea
@@ -4,6 +4,7 @@ require 'capistrano/devops/papertrail'
4
4
  require 'capistrano/devops/nginx'
5
5
  require 'capistrano/devops/redis'
6
6
  require 'capistrano/devops/rainbows'
7
+ require 'capistrano/devops/unicorn'
7
8
  require 'capistrano/devops/postgresql'
8
9
  require 'capistrano/devops/ssh'
9
10
  require 'capistrano/devops/utilities'
@@ -0,0 +1,67 @@
1
+ upstream backend_<%= fetch(:application) %> {
2
+ server unix:/tmp/unicorn.<%= fetch(:application) %>.sock fail_timeout=0;
3
+ }
4
+
5
+ server {
6
+ server_name <%= fetch(:server_name) %>;
7
+ listen 80 default deferred;
8
+
9
+ if (<%= fetch(:unicorn_force_ssl) %> = "true") {
10
+ if ($http_x_forwarded_proto = "http") {
11
+ return 301 https://$host$request_uri;
12
+ }
13
+ }
14
+
15
+ root <%= current_path %>/public;
16
+
17
+ location ^~ /assets/ {
18
+ gzip_static on;
19
+ expires max;
20
+ add_header Cache-Control public;
21
+ }
22
+
23
+ try_files $uri/index.html $uri @backend_<%= fetch(:application) %>;
24
+ location @backend_<%= fetch(:application) %> {
25
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
26
+ proxy_set_header Host $http_host;
27
+ proxy_set_header X-Real-IP $remote_addr;
28
+ proxy_redirect off;
29
+ proxy_pass http://backend_<%= fetch(:application) %>;
30
+ }
31
+
32
+ error_page 500 502 503 504 /500.html;
33
+ client_max_body_size 4G;
34
+ keepalive_timeout 10;
35
+ }
36
+
37
+ if (<%= fetch(:unicorn_force_ssl) %> = "true") {
38
+ server {
39
+ server_name <%= fetch(:server_name) %>;
40
+ listen 443;
41
+
42
+ ssl on;
43
+ ssl_certificate /etc/ssl/certs/<%= fetch(:server_name) %>.crt;
44
+ ssl_certificate_key /etc/ssl/private/server.key;
45
+
46
+ root <%= current_path %>/public;
47
+
48
+ location ^~ /assets/ {
49
+ gzip_static on;
50
+ expires max;
51
+ add_header Cache-Control public;
52
+ }
53
+
54
+ try_files $uri/index.html $uri @unicorn;
55
+ location @backend_<%= fetch(:application) %> {
56
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
57
+ proxy_set_header Host $http_host;
58
+ proxy_set_header X-Real-IP $remote_addr;
59
+ proxy_redirect off;
60
+ proxy_pass http://backend_<%= fetch(:application) %>;
61
+ }
62
+
63
+ error_page 500 502 503 504 /500.html;
64
+ client_max_body_size 4G;
65
+ keepalive_timeout 10;
66
+ }
67
+ }
@@ -0,0 +1,8 @@
1
+ working_directory "<%= current_path %>"
2
+ pid "<%= fetch(:unicorn_pid) %>"
3
+ stderr_path "<%= fetch(:unicorn_log) %>"
4
+ stdout_path "<%= fetch(:unicorn_log) %>"
5
+
6
+ listen "/tmp/unicorn.<%= fetch(:application) %>.sock"
7
+ worker_processes <%= fetch(:unicorn_workers) %>
8
+ timeout <%= fetch(:unicorn_timeout) %>
@@ -0,0 +1,75 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ # Feel free to change any of the following variables for your app:
5
+ TIMEOUT=${TIMEOUT-60}
6
+ APP_ROOT=<%= current_path %>
7
+ PID=<%= fetch(:unicorn_pid) %>
8
+ CMD="cd <%= current_path %>; bundle exec unicorn -D -c <%= fetch(:unicorn_config) -E <%= fetch(:rails_env, 'production') %>"
9
+ AS_USER=<%= fetch(:unicorn_user) %>
10
+ set -u
11
+
12
+ OLD_PIN="$PID.oldbin"
13
+
14
+ sig () {
15
+ test -s "$PID" && kill -$1 `cat $PID`
16
+ }
17
+
18
+ oldsig () {
19
+ test -s $OLD_PIN && kill -$1 `cat $OLD_PIN`
20
+ }
21
+
22
+ run () {
23
+ if [ "$(id -un)" = "$AS_USER" ]; then
24
+ eval $1
25
+ else
26
+ su -c "$1" - $AS_USER
27
+ fi
28
+ }
29
+
30
+ case "$1" in
31
+ start)
32
+ sig 0 && echo >&2 "Already running" && exit 0
33
+ run "$CMD"
34
+ ;;
35
+ stop)
36
+ sig QUIT && exit 0
37
+ echo >&2 "Not running"
38
+ ;;
39
+ force-stop)
40
+ sig TERM && exit 0
41
+ echo >&2 "Not running"
42
+ ;;
43
+ restart|reload)
44
+ sig HUP && echo reloaded OK && exit 0
45
+ echo >&2 "Couldn't reload, starting '$CMD' instead"
46
+ run "$CMD"
47
+ ;;
48
+ upgrade)
49
+ if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
50
+ then
51
+ n=$TIMEOUT
52
+ while test -s $OLD_PIN && test $n -ge 0
53
+ do
54
+ printf '.' && sleep 1 && n=$(( $n - 1 ))
55
+ done
56
+ echo
57
+
58
+ if test $n -lt 0 && test -s $OLD_PIN
59
+ then
60
+ echo >&2 "$OLD_PIN still exists after $TIMEOUT seconds"
61
+ exit 1
62
+ fi
63
+ exit 0
64
+ fi
65
+ echo >&2 "Couldn't upgrade, starting '$CMD' instead"
66
+ run "$CMD"
67
+ ;;
68
+ reopen-logs)
69
+ sig USR1
70
+ ;;
71
+ *)
72
+ echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
73
+ exit 1
74
+ ;;
75
+ esac
@@ -0,0 +1 @@
1
+ load File.expand_path("../../tasks/unicorn.rake", __FILE__)
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Devops
3
- VERSION = "0.0.11"
3
+ VERSION = "0.0.12"
4
4
  end
5
5
  end
@@ -0,0 +1,35 @@
1
+ set :unicorn_user, ->{ fetch(:user) }
2
+ set :unicorn_pid, ->{ "#{current_path}/tmp/pids/unicorn.pid" }
3
+ set :unicorn_config, ->{ "#{shared_path}/config/unicorn.rb" }
4
+ set :unicorn_log, ->{ "#{shared_path}/log/unicorn.log" }
5
+ set :unicorn_workers, 8
6
+ set :unicorn_timeout, 30
7
+ set :unicorn_force_ssl, false
8
+
9
+ namespace :unicorn do
10
+ desc "Setup unicorn initializer and app configuration"
11
+ task :setup do
12
+ on roles :app do
13
+ execute :mkdir, "-p #{shared_path}/config"
14
+
15
+ template "unicorn_init.erb", "/tmp/unicorn_init"
16
+ template 'unicorn.erb', "#{fetch(:unicorn_config)}"
17
+
18
+ execute :chmod, "+x /tmp/unicorn_init"
19
+ as(:root) do
20
+ execute :mv, "/tmp/unicorn_init /etc/init.d/unicorn_#{fetch(:application)}"
21
+ execute :'update-rc.d', "-f unicorn_#{fetch(:application)} defaults"
22
+ end
23
+ end
24
+ end
25
+
26
+ %w[start stop restart].each do |command|
27
+ desc "#{command} unicorn"
28
+ task command do
29
+ on roles(:app), in: :sequence, wait: 5 do
30
+ command_string = "unicorn_#{fetch(:application)} #{command}"
31
+ execute :service, command_string
32
+ end
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-devops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - tristan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-24 00:00:00.000000000 Z
11
+ date: 2014-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: capistrano-bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: yay
@@ -45,7 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
48
+ - ".gitignore"
49
49
  - Gemfile
50
50
  - LICENSE.txt
51
51
  - README.md
@@ -61,8 +61,12 @@ files:
61
61
  - lib/capistrano/devops/redis.rb
62
62
  - lib/capistrano/devops/ssh.rb
63
63
  - lib/capistrano/devops/templates/nginx_rainbows.erb
64
+ - lib/capistrano/devops/templates/nginx_unicorn.erb
64
65
  - lib/capistrano/devops/templates/rainbows.erb
65
66
  - lib/capistrano/devops/templates/rainbows_init.erb
67
+ - lib/capistrano/devops/templates/unicorn.erb
68
+ - lib/capistrano/devops/templates/unicorn_init.erb
69
+ - lib/capistrano/devops/unicorn.rb
66
70
  - lib/capistrano/devops/utilities.rb
67
71
  - lib/capistrano/devops/version.rb
68
72
  - lib/capistrano/tasks/nginx.rake
@@ -72,6 +76,7 @@ files:
72
76
  - lib/capistrano/tasks/redis.rake
73
77
  - lib/capistrano/tasks/set_rails_env.rake
74
78
  - lib/capistrano/tasks/ssh.rake
79
+ - lib/capistrano/tasks/unicorn.rake
75
80
  - lib/capistrano/tasks/utilities.rake
76
81
  - sample_app/.gitignore
77
82
  - sample_app/Capfile
@@ -140,17 +145,17 @@ require_paths:
140
145
  - lib
141
146
  required_ruby_version: !ruby/object:Gem::Requirement
142
147
  requirements:
143
- - - '>='
148
+ - - ">="
144
149
  - !ruby/object:Gem::Version
145
150
  version: '0'
146
151
  required_rubygems_version: !ruby/object:Gem::Requirement
147
152
  requirements:
148
- - - '>='
153
+ - - ">="
149
154
  - !ruby/object:Gem::Version
150
155
  version: '0'
151
156
  requirements: []
152
157
  rubyforge_project:
153
- rubygems_version: 2.1.11
158
+ rubygems_version: 2.2.2
154
159
  signing_key:
155
160
  specification_version: 4
156
161
  summary: yay