capistrano-rails-server 1.2.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/README.md +163 -173
- data/capistrano-rails-server.gemspec +19 -19
- data/lib/capistrano-rails-server.rb +16 -0
- data/lib/capistrano-rails-server/recipes/base.rb +16 -8
- data/lib/capistrano-rails-server/recipes/check.rb +1 -7
- data/lib/capistrano-rails-server/recipes/common.rb +18 -8
- data/lib/capistrano-rails-server/recipes/key.rb +23 -27
- data/lib/capistrano-rails-server/recipes/nginx.rb +10 -20
- data/lib/capistrano-rails-server/recipes/passenger.rb +23 -0
- data/lib/capistrano-rails-server/recipes/postfix.rb +26 -0
- data/lib/capistrano-rails-server/recipes/postgresql.rb +43 -22
- data/lib/capistrano-rails-server/recipes/rvm.rb +25 -0
- data/lib/capistrano-rails-server/recipes/templates/nginx_init.erb +75 -0
- data/lib/capistrano-rails-server/recipes/templates/nginx_passenger.erb +127 -0
- data/lib/capistrano-rails-server/recipes/templates/postfix_main.erb +39 -0
- data/lib/capistrano-rails-server/recipes/templates/postgresql.conf.erb +595 -0
- metadata +37 -19
- data/lib/capistrano-rails-server/recipes/rbenv.rb +0 -35
- data/lib/capistrano-rails-server/recipes/templates/nginx_unicorn.erb +0 -27
- data/lib/capistrano-rails-server/recipes/templates/unicorn.rb.erb +0 -8
- data/lib/capistrano-rails-server/recipes/templates/unicorn_init.erb +0 -84
- data/lib/capistrano-rails-server/recipes/unicorn.rb +0 -35
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MWY1NjBkOWI2NTQ4ODdhZmEzZTgwMWE4MTA1M2RkMWNjNGUyYTY4NWU4NzBh
|
10
|
-
Njg1ZjhiZTRhNzUwZWM0NjYwYWM1OTdhOGMxMTAxMWUzYTM5OGM2ZjNkMzdm
|
11
|
-
ZDExN2Q0NmI5ZDRkMzJlNTZhZWYzZmM2MDk3MWY3ZDU4YmNkYmM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MDFiYmUwOTJiOTI4ZWU1NTNjODZiY2U2MjM4MGU2MjBiMDRmMTMyOWU4ODY4
|
14
|
-
NTFiZDgxMDJjZjM4ZmVhOWRlM2I5NmFjYjZkZDAyNjE4MDM0OGVkOGQ4ZGU0
|
15
|
-
M2Y1NjAyMjllMmIwNjRjOTVjNWIxNTM4YjYwNThkYzNkYWUzNjE=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 613a89501daa928a62b27da2bfc2346f59f48993
|
4
|
+
data.tar.gz: ff8c701ecd4deb2b9461d56e36383fb6a3c7e0a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d6a5314403abc7b45316066de790b575bb178db2eb0f88122f4a82650b9fe3e3ab5132d2a7aeb4bc191c64bee97686bb705b53ea14779b0594ebd285117387f8
|
7
|
+
data.tar.gz: 10770ec5618d16b2b5ae57fd2c44770f16c976746dd702e3d258c8cc894cdc60e8221eaaed552787ccb44844841a2af49a10ccf3e2406cdef4a8e2a42a7d13f9
|
data/README.md
CHANGED
@@ -1,173 +1,163 @@
|
|
1
|
-
#capistrano-rails-server gem#
|
2
|
-
|
3
|
-
Capistrano-rails-server is collection of capistrano recipes for setting up production server for
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# uncomment this if you
|
29
|
-
#set :
|
30
|
-
#
|
31
|
-
|
32
|
-
#
|
33
|
-
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
set :
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
#
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
###
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
`
|
105
|
-
|
106
|
-
`
|
107
|
-
|
108
|
-
`
|
109
|
-
|
110
|
-
`
|
111
|
-
|
112
|
-
`
|
113
|
-
|
114
|
-
`
|
115
|
-
|
116
|
-
`
|
117
|
-
|
118
|
-
`
|
119
|
-
|
120
|
-
`
|
121
|
-
|
122
|
-
`
|
123
|
-
|
124
|
-
`
|
125
|
-
|
126
|
-
`
|
127
|
-
|
128
|
-
`
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
`
|
146
|
-
|
147
|
-
`
|
148
|
-
|
149
|
-
`
|
150
|
-
|
151
|
-
`
|
152
|
-
|
153
|
-
`
|
154
|
-
|
155
|
-
`
|
156
|
-
|
157
|
-
`postgresql_rebuild
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
`
|
162
|
-
|
163
|
-
`
|
164
|
-
|
165
|
-
`unicorn_env` - production or development
|
166
|
-
|
167
|
-
`unicorn_pid`
|
168
|
-
|
169
|
-
`unicorn_config`
|
170
|
-
|
171
|
-
`unicorn_log`
|
172
|
-
|
173
|
-
`unicorn_workers`
|
1
|
+
#capistrano-rails-server gem#
|
2
|
+
|
3
|
+
Capistrano-rails-server is a collection of capistrano recipes for setting up production server for RoR. The current testing environment is Ubuntu 12.04 LTS.
|
4
|
+
|
5
|
+
Components: RVM, Nginx, Passenger, Postgresql, Postfix
|
6
|
+
|
7
|
+
## Installation ##
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'capistrano-rails-server', :require => false
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle install
|
15
|
+
|
16
|
+
## Using ##
|
17
|
+
|
18
|
+
### Configure your app ###
|
19
|
+
Run `$ cap init` in your app folder if you don't have deploy.rb in your config dir (details [here](http://www.capistranorb.com/documentation/getting-started/preparing-your-application/)).
|
20
|
+
|
21
|
+
Then include these lines to the end of your `deploy.rb`:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
# uncomment this if you need non en-US locale for postgresql server
|
25
|
+
#set :postgresql_locale, "ru_RU"
|
26
|
+
#set :postgresql_rebuild, true
|
27
|
+
|
28
|
+
# uncomment this if you want to overwrite default config templates
|
29
|
+
#set :templates, {
|
30
|
+
# "nginx_passenger.erb" => File.expand_path("../templates/my_cool_nginx_template.erb", __FILE__),
|
31
|
+
# ...
|
32
|
+
#}
|
33
|
+
|
34
|
+
# uncomment this if you need another version of Ruby
|
35
|
+
#set_default :rvm_ruby_string, "2.0.0-p353"
|
36
|
+
#
|
37
|
+
# see other available params in documentation
|
38
|
+
# https://github.com/Drakula2k/capistrano-rails-server
|
39
|
+
|
40
|
+
|
41
|
+
# you can remove any recipe if you don't need it
|
42
|
+
set :capistrano_rails_server, [:base, :nginx, :passenger, :postgresql, :postfix, :rvm, :check, :key]
|
43
|
+
require 'capistrano-rails-server'
|
44
|
+
|
45
|
+
```
|
46
|
+
### Prepare server (instructions for Ubuntu 12.04) ###
|
47
|
+
|
48
|
+
Create admin group:
|
49
|
+
|
50
|
+
# addgroup admin
|
51
|
+
|
52
|
+
Create user for deployment:
|
53
|
+
|
54
|
+
# adduser yourappuser --ingroup admin
|
55
|
+
|
56
|
+
(Optional) Edit `/etc/sudoers` file if you don't want to enter user's password several time during recipes running (don't forget to undo it after installing!):
|
57
|
+
|
58
|
+
replace line
|
59
|
+
|
60
|
+
%admin ALL=(ALL) ALL
|
61
|
+
|
62
|
+
with
|
63
|
+
|
64
|
+
%admin ALL=(ALL) NOPASSWD:ALL
|
65
|
+
|
66
|
+
### Deploying ###
|
67
|
+
|
68
|
+
|
69
|
+
After that run command to install all software needed:
|
70
|
+
|
71
|
+
$ cap deploy:install
|
72
|
+
|
73
|
+
And configure it:
|
74
|
+
|
75
|
+
$ cap deploy:setup
|
76
|
+
|
77
|
+
|
78
|
+
Thats all, now you can deploy your app:
|
79
|
+
|
80
|
+
$ cap deploy
|
81
|
+
|
82
|
+
## Options ##
|
83
|
+
### Available cap tasks ###
|
84
|
+
`deploy:install` - install all software.
|
85
|
+
|
86
|
+
`deploy:setup` - configure all software.
|
87
|
+
|
88
|
+
`rvm_wrap:install`
|
89
|
+
|
90
|
+
`nginx:install`
|
91
|
+
|
92
|
+
`nginx:setup`
|
93
|
+
|
94
|
+
`nginx:start`
|
95
|
+
|
96
|
+
`nginx:stop`
|
97
|
+
|
98
|
+
`nginx:restart`
|
99
|
+
|
100
|
+
`passenger:setup`
|
101
|
+
|
102
|
+
`nginx:start`
|
103
|
+
|
104
|
+
`nginx:stop`
|
105
|
+
|
106
|
+
`passenger:restart`
|
107
|
+
|
108
|
+
`postgresql:install`
|
109
|
+
|
110
|
+
`postgresql:setup`
|
111
|
+
|
112
|
+
`postgresql:create_database`
|
113
|
+
|
114
|
+
`postgresql:rebuild` - rebuild Postgresql cluster with given locale and encoding. WARNING! This task removes all existing databases.
|
115
|
+
|
116
|
+
`postgresql:import`
|
117
|
+
|
118
|
+
`postgresql:export`
|
119
|
+
|
120
|
+
`key:generate`
|
121
|
+
|
122
|
+
`key:show` - show generated deployment key.
|
123
|
+
|
124
|
+
`key:remove`
|
125
|
+
|
126
|
+
`postfix:install`
|
127
|
+
|
128
|
+
`postfix:stats` - show postfix stats
|
129
|
+
|
130
|
+
### Available options and defaults for all recipes###
|
131
|
+
You can overwrite any of these options in `deploy.rb` file.
|
132
|
+
|
133
|
+
#### system ####
|
134
|
+
|
135
|
+
`system_codename` ("precise") - system codename for repositories
|
136
|
+
|
137
|
+
`templates` - configs templates overrides
|
138
|
+
|
139
|
+
#### :rvm ####
|
140
|
+
|
141
|
+
`rvm_ruby_string` ("2.0.0-p353")
|
142
|
+
|
143
|
+
#### :postgresql ####
|
144
|
+
|
145
|
+
`postgresql_host` ("localhost")
|
146
|
+
|
147
|
+
`postgresql_user` (application)
|
148
|
+
|
149
|
+
`postgresql_password` (console password_prompt)
|
150
|
+
|
151
|
+
`postgresql_database` ("#{application}_production")
|
152
|
+
|
153
|
+
`postgresql_rebuild` (false)
|
154
|
+
|
155
|
+
`postgresql_encoding` ("UTF-8") - useful only if postgresql_rebuild is true
|
156
|
+
|
157
|
+
`postgresql_locale` ("en_US") - useful only if postgresql_rebuild is true
|
158
|
+
|
159
|
+
#### :passenger ####
|
160
|
+
|
161
|
+
`passenger_user` (user)
|
162
|
+
|
163
|
+
`passenger_env` ("production") - production or development
|
@@ -1,20 +1,20 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
7
|
-
s.version =
|
8
|
-
s.date =
|
9
|
-
s.summary = "Capistrano recipes to setup
|
10
|
-
s.description =
|
11
|
-
|
12
|
-
s.authors = ["Drakula2k"]
|
13
|
-
s.email =
|
14
|
-
s.homepage =
|
15
|
-
s.files = `git ls-files`.split($/)
|
16
|
-
s.require_paths = ["lib"]
|
17
|
-
s.add_dependency "capistrano"
|
18
|
-
s.
|
19
|
-
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "capistrano-rails-server"
|
7
|
+
s.version = "2.0.2"
|
8
|
+
s.date = "2014-03-27"
|
9
|
+
s.summary = "Capistrano recipes to setup RVM, Nginx, Passenger, Postgresql and Postfix production environment."
|
10
|
+
s.description =
|
11
|
+
"That gem includes capistrano recipes to install and configure ROR production environment with RVM, Nginx, Passenger, Postgresql and Postfix."
|
12
|
+
s.authors = ["Drakula2k"]
|
13
|
+
s.email = "drakula2k@gmail.com"
|
14
|
+
s.homepage = "https://github.com/Drakula2k/capistrano-rails-server"
|
15
|
+
s.files = `git ls-files`.split($/)
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.add_dependency "capistrano", "~> 2.15"
|
18
|
+
s.add_dependency "rvm-capistrano", "~> 1.5"
|
19
|
+
s.add_development_dependency "rake"
|
20
20
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'capistrano-rails-server/recipes/common'
|
2
|
+
|
3
|
+
@configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
4
|
+
Capistrano::Configuration.instance(:must_exist) :
|
5
|
+
Capistrano.configuration(:must_exist)
|
6
|
+
|
7
|
+
@configuration.load do
|
8
|
+
set_default(:capistrano_rails_server, [:base, :nginx, :passenger, :postgresql, :postfix, :rvm, :check, :key])
|
9
|
+
set_default(:system_codename, "precise")
|
10
|
+
set_default(:templates, {})
|
11
|
+
|
12
|
+
capistrano_rails_server.each do |recipe|
|
13
|
+
require "capistrano-rails-server/recipes/#{recipe}"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -1,15 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
4
|
-
Capistrano::Configuration.instance(:must_exist) :
|
5
|
-
Capistrano.configuration(:must_exist)
|
6
|
-
|
7
|
-
configuration.load do
|
1
|
+
@configuration.load do
|
8
2
|
namespace :deploy do
|
3
|
+
desc "Increase SSH timeouts for running long operations like Ruby compiling"
|
4
|
+
task :ssh do
|
5
|
+
cmd = %Q{grep -R "ClientAliveInterval" /etc/ssh/sshd_config}
|
6
|
+
content = capture( %Q{bash -c '#{cmd}' || echo "false"}).strip
|
7
|
+
if content == 'false'
|
8
|
+
run %Q{#{sudo} bash -c "echo 'ClientAliveInterval 18' >> /etc/ssh/sshd_config"}
|
9
|
+
run %Q{#{sudo} bash -c "echo 'ClientAliveCountMax 100' >> /etc/ssh/sshd_config"}
|
10
|
+
run "#{sudo} service ssh restart"
|
11
|
+
else
|
12
|
+
run 'echo "sshd_config is already updated!"'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
before "deploy:install", "deploy:ssh"
|
16
|
+
|
9
17
|
desc "Install everything onto the server"
|
10
18
|
task :install do
|
11
19
|
run "#{sudo} apt-get -y update"
|
12
|
-
run "#{sudo} apt-get -y install python-software-properties software-properties-common"
|
20
|
+
run "#{sudo} apt-get -y install python-software-properties software-properties-common git"
|
13
21
|
end
|
14
22
|
|
15
23
|
# Overwrite with no sudo
|
@@ -1,10 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
4
|
-
Capistrano::Configuration.instance(:must_exist) :
|
5
|
-
Capistrano.configuration(:must_exist)
|
6
|
-
|
7
|
-
configuration.load do
|
1
|
+
@configuration.load do
|
8
2
|
namespace :check do
|
9
3
|
desc "Make sure local git is in sync with remote."
|
10
4
|
task :revision, roles: :web do
|