deployer 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1 -1
- data/README.md +213 -0
- data/lib/deployer/helpers.rb +40 -10
- data/lib/deployer/initializer.rb +2 -2
- data/lib/deployer.rb +19 -21
- data/lib/tasks/commands.rb +2 -2
- data/lib/tasks/db.rb +16 -18
- data/lib/tasks/gems.rb +6 -2
- data/lib/tasks/global.rb +12 -28
- data/lib/tasks/passenger.rb +1 -1
- data/lib/tasks/plugin.rb +7 -7
- data/setup/deploy.rb +35 -50
- metadata +54 -29
- data/.document +0 -4
- data/.gitignore +0 -21
- data/README.textile +0 -290
- data/Rakefile +0 -52
- data/VERSION +0 -1
- data/deployer.gemspec +0 -64
- data/lib/deployer/tasks/deployer.rake +0 -18
- data/lib/tasks/apache.rb +0 -49
- data/lib/tasks/nginx.rb +0 -47
data/setup/deploy.rb
CHANGED
@@ -5,98 +5,83 @@
|
|
5
5
|
# http://github.com/meskyanichi/deployer
|
6
6
|
#
|
7
7
|
# Create Local and Remote Repository:
|
8
|
+
# This will create a git repository on the deployment server
|
9
|
+
# Will not work when using a remote location such as github.com, trunksapp.com
|
8
10
|
# git init
|
9
11
|
# cap deploy:repository:create
|
10
12
|
#
|
11
13
|
# Initial Deployment:
|
12
14
|
# git add .
|
13
|
-
# git commit -
|
14
|
-
# git push origin
|
15
|
+
# git commit -m "Initial commit for deployment"
|
16
|
+
# git push origin [:branch]
|
15
17
|
# cap deploy:initial
|
16
18
|
#
|
17
19
|
# Then For Every Update Just Do:
|
18
20
|
# git add .
|
19
21
|
# git commit -am "some other commit"
|
20
|
-
# git push origin
|
22
|
+
# git push origin [:branch]
|
21
23
|
# cap deploy
|
22
24
|
#
|
23
|
-
# For Apache2 Users
|
24
|
-
# cap deploy:apache:create
|
25
|
-
# cap deploy:apache:destroy
|
26
|
-
# cap deploy:apache:restart
|
27
|
-
# cap deploy:apache:destroy_all
|
28
|
-
#
|
29
|
-
# For NginX Users
|
30
|
-
# cap deploy:nginx:create
|
31
|
-
# cap deploy:nginx:destroy
|
32
|
-
# cap deploy:nginx:restart
|
33
|
-
# cap deploy:nginx:destroy_all
|
34
|
-
#
|
35
25
|
# For a Full List of Commands
|
36
26
|
# cap -T
|
37
27
|
|
38
28
|
|
29
|
+
##
|
39
30
|
# Essential Configuration
|
40
31
|
# Assumes Application and Git Repository are located on the same server
|
41
|
-
set :
|
42
|
-
set :
|
43
|
-
set :
|
44
|
-
set :
|
45
|
-
set :
|
46
|
-
|
32
|
+
set :appname, "example.com" # the name of your application
|
33
|
+
set :ip, "123.45.678.90" # the ip address of the production server
|
34
|
+
set :user, "deployer" # the user that will deploy to the production server
|
35
|
+
set :remote, "origin" # the remote that should be deployed
|
36
|
+
set :branch, "production" # the branch that should be deployed
|
37
|
+
|
47
38
|
|
39
|
+
##
|
48
40
|
# Optional
|
49
|
-
# If
|
50
|
-
#
|
51
|
-
#
|
52
|
-
# You will have to manually create the repository yourself on the specified server.
|
53
|
-
#
|
54
|
-
# set :repository_url, "root@example.com:/path/to/repository.git"
|
41
|
+
# If you want to use a repository from a different location (github.com, trunksapp.com, etc)
|
42
|
+
# Then you can specify the URL here. When using this, the "cap deploy:repository" tasks won't work.
|
43
|
+
# set :repository_url, "deployer@example.com:/path/to/repository.git"
|
55
44
|
|
56
45
|
|
46
|
+
##
|
57
47
|
# Set up additional shared folders
|
58
48
|
set :additional_shared_folders,
|
59
|
-
%w(public/
|
49
|
+
%w(public/system db)
|
50
|
+
|
60
51
|
|
52
|
+
##
|
61
53
|
# Set up additional shared symlinks
|
62
54
|
# These are mirrored to the Rails Applications' structure
|
63
|
-
# public/
|
55
|
+
# public/system = RAILS_ROOT/public/system => SHARED_PATH/public/system
|
64
56
|
# db/production.sqlite3 = RAILS_ROOT/db/production.sqlite3 => SHARED_PATH/db/production.sqlite3
|
65
57
|
set :additional_shared_symlinks,
|
66
|
-
%w(public/
|
58
|
+
%w(public/system db/production.sqlite3)
|
67
59
|
|
68
60
|
|
61
|
+
##
|
69
62
|
# Additional Application Specific Tasks and Callbacks
|
70
|
-
# In here you can specify which Application Specific tasks you would like to run right before
|
71
|
-
#
|
72
|
-
#
|
63
|
+
# In here you can specify which Application Specific tasks you would like to run right before
|
64
|
+
# Passenger restarts the application. You invoke the by simply calling "run_custom_task"
|
65
|
+
# For a list of all the available tasks that you could add to this "after_deploy" method, run: cap -T
|
73
66
|
def after_deploy
|
74
|
-
run_custom_task "my_custom_task"
|
75
|
-
run_custom_task "nested:my_custom_task"
|
67
|
+
# run_custom_task "my_custom_task"
|
68
|
+
# run_custom_task "nested:my_custom_task"
|
76
69
|
end
|
77
70
|
|
71
|
+
##
|
78
72
|
# Application Specific Deployment Tasks
|
79
73
|
# In here you may specify any application specific and/or other tasks that are not handled by Deployer
|
74
|
+
# These can be invoked by creating a "run_custom_task" method in the "after_deploy" method above
|
80
75
|
namespace :deploy do
|
81
|
-
desc "
|
76
|
+
desc "Invoke this task manually by running: 'cap deploy:my_custom_task'"
|
82
77
|
task :my_custom_task do
|
83
|
-
run "
|
78
|
+
# run "some command"
|
84
79
|
end
|
85
80
|
|
86
81
|
namespace :nested do
|
87
|
-
desc "
|
82
|
+
desc "Invoke this task manually by running: 'cap deploy:nested:my_custom_task'"
|
88
83
|
task :my_custom_task do
|
89
|
-
system "
|
84
|
+
# system "some command"
|
90
85
|
end
|
91
86
|
end
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
# Default Configuration Apache/NginX
|
96
|
-
# The settings below are default, you do not need to set these, unless you want to specify other parameters.
|
97
|
-
# If you find that the settings below are fine, then you can leave them commented out or just remove them.
|
98
|
-
#
|
99
|
-
# set :apache_initialize_utility_path, '/etc/init.d/apache2' # Only applies if running Apache and using the Apache Tasks
|
100
|
-
# set :apache_sites_available_path, '/etc/apache2/sites-available' # Only applies if running Apache and using the Apache Tasks
|
101
|
-
# set :nginx_initialize_utility_path, '/etc/init.d/nginx' # Only applies if running NginX and using the NginX Tasks
|
102
|
-
# set :nginx_sites_enabled_path, '/opt/nginx/conf/sites-enabled' # Only applies if running NginX and using the NginX Tasks
|
87
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deployer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 31
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Michael van Rooijen
|
@@ -9,79 +15,98 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
13
|
-
default_executable:
|
18
|
+
date: 2010-06-13 00:00:00 +02:00
|
19
|
+
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: capistrano
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 1
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 5
|
33
|
+
- 13
|
23
34
|
version: 2.5.13
|
24
|
-
|
25
|
-
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: OptionParser
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 9
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 5
|
49
|
+
- 1
|
50
|
+
version: 0.5.1
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
description: Deployer is gem that enhances Capistrano to simplify the deployment of Ruby on Rails applications.
|
26
54
|
email: meskyanichi@gmail.com
|
27
55
|
executables:
|
28
56
|
- enhancify
|
29
57
|
extensions: []
|
30
58
|
|
31
|
-
extra_rdoc_files:
|
32
|
-
|
33
|
-
- README.textile
|
59
|
+
extra_rdoc_files: []
|
60
|
+
|
34
61
|
files:
|
35
|
-
- .document
|
36
|
-
- .gitignore
|
37
|
-
- LICENSE
|
38
|
-
- README.textile
|
39
|
-
- Rakefile
|
40
|
-
- VERSION
|
41
62
|
- bin/enhancify
|
42
|
-
- deployer.gemspec
|
43
|
-
- lib/deployer.rb
|
44
63
|
- lib/deployer/helpers.rb
|
45
64
|
- lib/deployer/initializer.rb
|
46
|
-
- lib/deployer
|
47
|
-
- lib/tasks/apache.rb
|
65
|
+
- lib/deployer.rb
|
48
66
|
- lib/tasks/commands.rb
|
49
67
|
- lib/tasks/db.rb
|
50
68
|
- lib/tasks/environment.rb
|
51
69
|
- lib/tasks/gems.rb
|
52
70
|
- lib/tasks/global.rb
|
53
|
-
- lib/tasks/nginx.rb
|
54
71
|
- lib/tasks/passenger.rb
|
55
72
|
- lib/tasks/plugin.rb
|
56
73
|
- lib/tasks/repository.rb
|
57
74
|
- setup/deploy.rb
|
75
|
+
- README.md
|
76
|
+
- LICENSE
|
58
77
|
has_rdoc: true
|
59
|
-
homepage:
|
78
|
+
homepage: http://github.com/meskyanichi/deployer
|
60
79
|
licenses: []
|
61
80
|
|
62
81
|
post_install_message:
|
63
|
-
rdoc_options:
|
64
|
-
|
82
|
+
rdoc_options: []
|
83
|
+
|
65
84
|
require_paths:
|
66
85
|
- lib
|
67
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
68
88
|
requirements:
|
69
89
|
- - ">="
|
70
90
|
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
92
|
+
segments:
|
93
|
+
- 0
|
71
94
|
version: "0"
|
72
|
-
version:
|
73
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
74
97
|
requirements:
|
75
98
|
- - ">="
|
76
99
|
- !ruby/object:Gem::Version
|
100
|
+
hash: 3
|
101
|
+
segments:
|
102
|
+
- 0
|
77
103
|
version: "0"
|
78
|
-
version:
|
79
104
|
requirements: []
|
80
105
|
|
81
106
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.3.
|
107
|
+
rubygems_version: 1.3.7
|
83
108
|
signing_key:
|
84
109
|
specification_version: 3
|
85
|
-
summary: Deployer is
|
110
|
+
summary: Deployer is gem that enhances Capistrano to simplify the deployment of Ruby on Rails applications.
|
86
111
|
test_files: []
|
87
112
|
|
data/.document
DELETED
data/.gitignore
DELETED
data/README.textile
DELETED
@@ -1,290 +0,0 @@
|
|
1
|
-
h1. Deployer
|
2
|
-
|
3
|
-
p. Deployer is a deployment engine (Ruby Gem) that enhances Capistrano with a set of useful automated deployment tasks and a base structure. It favors convention over configuration, and it simplifies Rails Application Deployment with Capistrano.
|
4
|
-
|
5
|
-
p. It assumes you are using Passenger to serve your Rails applications.
|
6
|
-
|
7
|
-
h2. Why?
|
8
|
-
|
9
|
-
p. I wanted a tool that'd enhance Capistrano's default setup, and I wanted it to cause me a minimal amount of hassle and time consumption to set up as well for every time I want to deploy a new application.
|
10
|
-
|
11
|
-
|
12
|
-
h2. Getting Started
|
13
|
-
|
14
|
-
p. install the gem
|
15
|
-
|
16
|
-
bc. sudo gem install deployer
|
17
|
-
|
18
|
-
p. create a new Rails app
|
19
|
-
|
20
|
-
bc. rails my_application
|
21
|
-
|
22
|
-
p. move into the Rails app and execute the "capify" and "enhancify" commands
|
23
|
-
|
24
|
-
bc. cd my_application
|
25
|
-
capify .
|
26
|
-
enhancify .
|
27
|
-
|
28
|
-
p. enhancify is a command, provided by deployer that will inject some code into the Capfile and replace the config/deploy.rb with the one used for *Deployer*.
|
29
|
-
If the deploy.rb file already exists, it will simply rename it to "deploy.old.1.rb", and if that also exists it will rename it to deploy.old.2.rb, etc. etc. So you will never accidentally overwrite your initial deploy.rb file.
|
30
|
-
|
31
|
-
p. This is what the deploy.rb looks like: "config/deploy.rb":http://github.com/meskyanichi/deployer/blob/master/setup/deploy.rb
|
32
|
-
|
33
|
-
p. *Next, open the config/deploy.rb file and edit the following variables.*
|
34
|
-
|
35
|
-
bc. set :ip, "123.45.678.90" # the ip address that points to your production server
|
36
|
-
set :user, "root" # the user that will connect to the production server
|
37
|
-
set :remote, "origin" # the remote that should be deployed
|
38
|
-
set :branch, "master" # the branch that should be deployed
|
39
|
-
set :domain, "example.com" # (or set :domain, "subdomain.example.com"
|
40
|
-
set :subdomain, false # and set :subdomain, true)
|
41
|
-
|
42
|
-
p. For the sake of *testing*, be sure to *NOT* test this out on your main domain, unless you don't have an application running there that is. In the above example you can see how you set this up for a subdomain for your application to deploy a sample Rails Application to try out *Deployer*.
|
43
|
-
|
44
|
-
bc. set :domain, "test.mydomain.com"
|
45
|
-
set :subdomain, true
|
46
|
-
|
47
|
-
p. _This is what you must do if you wish to try it out on a subdomain. In this case: test.mydomain.com_
|
48
|
-
|
49
|
-
p. And *that's it!* You are now ready to do the following through *Deployer*:
|
50
|
-
|
51
|
-
* Create a remote git repository
|
52
|
-
* Push your initial commit to the remote repository
|
53
|
-
* Create the production environment to where you will deploy your application to
|
54
|
-
* Let *Deployer* create a simple Apache2 or NginX virtual-host file, transfer it to your remote server and restart the web-server
|
55
|
-
* And, of course, deploy and run your Rails application!
|
56
|
-
|
57
|
-
p. Here is are the quick-reference comments of the config/deploy.rb file
|
58
|
-
|
59
|
-
bc. # Quick Reference
|
60
|
-
# Configure the essential configurations below and do the following:
|
61
|
-
#
|
62
|
-
# Create Local and Remote Repository:
|
63
|
-
# git init
|
64
|
-
# cap deploy:repository:create
|
65
|
-
#
|
66
|
-
# Initial Deployment:
|
67
|
-
# git add .
|
68
|
-
# git commit -am "Initial commit for deployment"
|
69
|
-
# git push origin master
|
70
|
-
# cap deploy:initial
|
71
|
-
#
|
72
|
-
# Then For Every Update Just Do:
|
73
|
-
# git add .
|
74
|
-
# git commit -am "some other commit"
|
75
|
-
# git push origin master
|
76
|
-
# cap deploy
|
77
|
-
#
|
78
|
-
# For Apache2 Users
|
79
|
-
# cap deploy:apache:create
|
80
|
-
# cap deploy:apache:destroy
|
81
|
-
# cap deploy:apache:restart
|
82
|
-
# cap deploy:apache:destroy_all
|
83
|
-
#
|
84
|
-
# For NginX Users
|
85
|
-
# cap deploy:nginx:create
|
86
|
-
# cap deploy:nginx:destroy
|
87
|
-
# cap deploy:nginx:restart
|
88
|
-
# cap deploy:nginx:destroy_all
|
89
|
-
#
|
90
|
-
# For a Full List of Commands
|
91
|
-
# cap -T
|
92
|
-
|
93
|
-
p. *NOTE*
|
94
|
-
|
95
|
-
p. The Apache2 and NginX tasks are totally OPTIONAL. Before you use these, please scroll down this page and see what it's all about. It essentially parses an initial *apache* or *nginx* virtual host file. Once parsed, it will transfer this inside the sites-available / sites-enabled folders. Afterwards *Apache* or *Nginx* will automatically get restarted. So basically you COULD deploy a web application without ever manually *SSH*'ing into the production box. I use this, but again, please read more about this before attempting it just so you know whats going on if it doesn't work for you. It depends on various things. It's optional so you don't have to use these methods since we're talking about *deployment* and not *server management*, it's just a simple little extra that *Deployer* provides, nothing really fancy.
|
96
|
-
|
97
|
-
p. There are more tasks, but these will be your main commands. It's pretty straightforward.
|
98
|
-
|
99
|
-
p. To list all commands:
|
100
|
-
|
101
|
-
bc. cap -T
|
102
|
-
|
103
|
-
|
104
|
-
h3. Automated Tasks
|
105
|
-
|
106
|
-
p. *Deployer* will invoke various built-in tasks to try and deploy your application successfully.
|
107
|
-
|
108
|
-
p. On the initial deployment *cap deploy:initial*. This procedure only has to be performed once.
|
109
|
-
|
110
|
-
* It will setup the production environment, releases and shared folder
|
111
|
-
* It will populate the shared folder with the folders you specified in the deploy.rb file
|
112
|
-
* It will sync your applications *database.yml* file to the shared/db folder
|
113
|
-
* It will sync the *deployer.rake* task from the to the shared/lib/tasks folder
|
114
|
-
* It will deploy your application
|
115
|
-
|
116
|
-
p. And the deployment procedure that follows (*cap deploy*), does the following:
|
117
|
-
|
118
|
-
* It will create a new folder in the releases folder and deploy your application to it
|
119
|
-
* It will ensure that the shared folder has all the folders you specified in the *deploy.rb*
|
120
|
-
* It will setup built-in symlink setups for your database.yml, production log and deployer.rake
|
121
|
-
* It will also setup any additional symlinks you may have specified inside the *deploy.rb* from the release folder to the shared folder
|
122
|
-
* It will ensure all gems that are specified inside the *config/environment.rb* are installed. Will attempt to ignore exceptions
|
123
|
-
* It will ensure the database is present and migrated to the latest version
|
124
|
-
* It will then perform any *custom* tasks you might have specified inside the *deploy.rb* file within the *after_deploy* method definition
|
125
|
-
* It will then set the correct passenger permissions
|
126
|
-
* It will then restart passenger
|
127
|
-
|
128
|
-
p. The *cap deploy:initial* will call *cap deploy* at the end. So an initial version will be released. After that, just do the following to released a new version as you normally would:
|
129
|
-
|
130
|
-
bc. git add .
|
131
|
-
git commit -am "next version commit"
|
132
|
-
git push origin master
|
133
|
-
cap deploy
|
134
|
-
|
135
|
-
|
136
|
-
h2. Additional Configuration
|
137
|
-
|
138
|
-
*Shared Folders and Symlinks*
|
139
|
-
|
140
|
-
p. I wanted to keep this as simple as possible as well. By default, *Deployer* will create folders for storing the production.log in and other necessary stuff.
|
141
|
-
It will properly symlink it from the shared folder to the Rails application. However! You will most likely have some other things you must keep in a shared folder, such as assets
|
142
|
-
or other files. This can be done easily with *Deployer*.
|
143
|
-
|
144
|
-
p. Again, inside of config/deploy.rb
|
145
|
-
|
146
|
-
bc. set :additional_shared_folders,
|
147
|
-
%w(public/assets db)
|
148
|
-
|
149
|
-
p. In this example two paths will be created.
|
150
|
-
|
151
|
-
* /var/rails/:domain/shared/public/assets
|
152
|
-
* /var/rails/:domain/shared/db
|
153
|
-
|
154
|
-
p. *Deployer* will ensure these are available after every deployment. And will append any folders if you change the values here and re-deploy.
|
155
|
-
|
156
|
-
p. Now, what use are these folders if you do not have the ability to add symlinks from these folders to the application.
|
157
|
-
|
158
|
-
bc. set :additional_shared_symlinks,
|
159
|
-
%w(public/assets db/production.sqlite3)
|
160
|
-
|
161
|
-
p. In this example two symlinks will be created from the shared_path to the current Rails application release.
|
162
|
-
As you can see the first symlink is a "path" symlink, which does not point to a direct file, but rather a folder.
|
163
|
-
|
164
|
-
p. The second symlink will be a link from the shared/db/production.sqlite3 to the current rails applications' db/production.sqlite3 file.
|
165
|
-
|
166
|
-
*NOTE*
|
167
|
-
|
168
|
-
p. One important thing to note here is that notice how the symlinks are mirrored to the Rails applications folder structure. This will always be the case. If you have some crazy architecture inside your Rails application: *rails_root/my/awesome/folder/structure/is/very/long* then you MUST create the following folder structure for the shared path: *shared/my/awesome/folder/structure/is/very/long*. This is a convention and it saves a lot of overhead in your configuration file by just defining a path once and using that same path for both the current and shared path.
|
169
|
-
|
170
|
-
p. *Additional (Optional) (Server) Configuration*
|
171
|
-
|
172
|
-
p. Here you can specify that you want to pull/push from/to a git repository that's located on a DIFFERENT server. Leave this commented out or remove it if your git repository resides on the same server as your Rails application. If you choose to store your git repository on a separate server by uncommenting the following line, then you lose the ability to create/reset/destroy/reinitialize it through *Deployer*. This is no big deal though. All you have to do is create the git repository manually on that specific server and then issue the *git remote add origin repository_url* and it will work fine with the rest of *Deployer*.
|
173
|
-
|
174
|
-
bc. set :repository_url, "root@example.com:/path/to/repository.git"
|
175
|
-
|
176
|
-
p. And then here is the last bit of server configuration you can specify.
|
177
|
-
|
178
|
-
bc. # Default Configuration (Git/Repository Apache/NginX)
|
179
|
-
# The settings below are default, you do not need to set these, unless you want to specify other parameters.
|
180
|
-
# If you find that the settings below are fine, then you can leave them commented out or just remove them.
|
181
|
-
#
|
182
|
-
# set :apache_initialize_utility_path, '/etc/init.d/apache2' # Only applies if running Apache and using the Apache Tasks
|
183
|
-
# set :apache_sites_available_path, '/etc/apache2/sites-available' # Only applies if running Apache and using the Apache Tasks
|
184
|
-
# set :nginx_initialize_utility_path, '/etc/init.d/nginx' # Only applies if running NginX and using the NginX Tasks
|
185
|
-
# set :nginx_sites_enabled_path, '/opt/nginx/conf/sites-enabled' # Only applies if running NginX and using the NginX Tasks
|
186
|
-
|
187
|
-
p. Again, very straightforward. I even added comments. One thing to note here is that these are commented out by default and you don't have to "uncomment" them to get the defaults. If you like the default settings you can leave it commented out, or just remove the lines. Or of course, uncomment them and leave them unchanged. Whatever you want.
|
188
|
-
|
189
|
-
|
190
|
-
h3. *Adding Application Specific Deployment Tasks*
|
191
|
-
|
192
|
-
p. Inside the *namespace :deploy do* block you can define your own deployment tasks that are specific to your application.
|
193
|
-
|
194
|
-
bc.. # Application Specific Deployment Tasks
|
195
|
-
namespace :deploy do
|
196
|
-
|
197
|
-
desc "This is my custom task."
|
198
|
-
task :my_custom_task do
|
199
|
-
run "ls #{shared_path}"
|
200
|
-
end
|
201
|
-
|
202
|
-
namespace :nested do
|
203
|
-
desc "This is my nested custom task."
|
204
|
-
task :my_custom_task do
|
205
|
-
puts "ls #{shared_path}"
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
end
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
p. Again, very straightforward. Just define your tasks as you normally would with Capistrano.
|
214
|
-
Then, to invoke them during each deployment you must add them inside the *after_deploy*, method like so:
|
215
|
-
|
216
|
-
bc. def after_deploy
|
217
|
-
run_custom_task "my_custom_task"
|
218
|
-
run_custom_task "nested:my_custom_task"
|
219
|
-
end
|
220
|
-
|
221
|
-
p. This method will be invoked right before *Deployer* sets permissions on, and restarts the your Rails application.
|
222
|
-
|
223
|
-
|
224
|
-
h3. Built-in Additional Tasks
|
225
|
-
|
226
|
-
p. *Deployer* has some built-in tasks that are often used by developers.
|
227
|
-
|
228
|
-
p. *Whenever*, To update the crontab on deployment:
|
229
|
-
|
230
|
-
bc. def after_deploy
|
231
|
-
run_custom_task "whenever:update_crontab"
|
232
|
-
end
|
233
|
-
|
234
|
-
p. *Delayed Job*, To start/stop daemons
|
235
|
-
|
236
|
-
bc. def after_deploy
|
237
|
-
run_custom_task "delayed_job:start"
|
238
|
-
run_custom_task "delayed_job:start n=3" # "n" specifies the amount of daemons that should run
|
239
|
-
run_custom_task "delayed_job:stop"
|
240
|
-
end
|
241
|
-
|
242
|
-
|
243
|
-
h2. Assumptions / Conventions
|
244
|
-
|
245
|
-
p. Deployer favors Convention of Configuration. There are a few things you need to be aware of before you start using it. Just so it doesn't confuse you.
|
246
|
-
|
247
|
-
p. By filling in the 4 variables (ip, domain, subdomain, user) you are practically set to create a remote git repository, push your local repository to it, create your production environment, deploy to your production environment from your remote repository and even let *Deployer* parse the simple apache2 and nginx configuration vhost files and transfer them to the server. Of course, you can also just choose to do setup your virtual hosts manually, it is totally optional. The availability of this option depends on your OS architecture/webserver installation path.
|
248
|
-
|
249
|
-
p. Now, just to clear some things up with some facts about the conventions:
|
250
|
-
|
251
|
-
*Rails Application Deployment Path*
|
252
|
-
|
253
|
-
bc. /var/rails/:domain
|
254
|
-
|
255
|
-
*Git Repository Path* unless specified otherwise in the configuration file.
|
256
|
-
|
257
|
-
bc. /var/git/:domain.git
|
258
|
-
|
259
|
-
*If using the Apache2 create/destroy/restart/destroy_all features, Apache2's sites-available path must be the following*, unless specified otherwise in the configuration file.
|
260
|
-
|
261
|
-
bc. /etc/apache2/sites-available/
|
262
|
-
|
263
|
-
*If using the NginX create/destroy/restart/destroy_all features, NginX's sites-enabled path must be the following*, unless specified otherwise in the configuration file.
|
264
|
-
|
265
|
-
bc. /opt/nginx/conf/sites-enabled/
|
266
|
-
|
267
|
-
p. Additionally, you must be able to start/stop the NginX webserver through these commands: "/etc/init.d/nginx start" and "/etc/init.d/nginx stop"
|
268
|
-
If you don't have this functionality, but want it, check out: "http://github.com/meskyanichi/rails-nginx-passenger-ubuntu":http://github.com/meskyanichi/rails-nginx-passenger-ubuntu
|
269
|
-
For NginX you must also add this: *include sites-enabled/** inside the nginx configuration file, inside the *server{}* block to include all settings that *Deployer* transfers into the sites-enabled
|
270
|
-
|
271
|
-
* Assumes you are using Phusion Passenger for deployment
|
272
|
-
* Assumes Git Repository will be located on the same server as where the actual application will be deployed. Unless specified otherwise in the configuration file.
|
273
|
-
* The config/database.yml will be transferred to the shared/config/database.yml and symlinked to on the initial deployment. You can re-sync it later with *cap deploy:db:sync_yaml*.
|
274
|
-
* I have overwritten/adjusted the "rake gems:install" command in production mode to try and force a successful gem installation process.
|
275
|
-
There are occasions where there are unexpected exceptions raised when trying to issue the rake task. For example when you have an "Uninitialized Constant" inside the environment.rb which "is" initialized in development mode because you have the gem installed locally, but fails in the production environment because it does not have the gem. *Deployer* shall try to install any gem specified inside the config/environment.rb regardless of what exception is being raised to ensure all gem dependencies are installed on deployment.
|
276
|
-
|
277
|
-
|
278
|
-
*NOTE*
|
279
|
-
|
280
|
-
p. This is a _very early_ release. A lot may be subject to change, for the good!
|
281
|
-
|
282
|
-
|
283
|
-
h2. Suggestions, Requests, Idea's?
|
284
|
-
|
285
|
-
Tell, Ask, Fork and Help!
|
286
|
-
|
287
|
-
|
288
|
-
h2. Copyright
|
289
|
-
|
290
|
-
Copyright (c) 2010 Michael van Rooijen. See LICENSE for details.
|
data/Rakefile
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "deployer"
|
8
|
-
gem.summary = %Q{Deployer is a deployment engine (Ruby Gem) that enhances Capistrano with a set of useful automated deployment tasks. It favors convention over configuration, and it simplifies Rails Application Deployment with Capistrano.}
|
9
|
-
gem.description = %Q{Deployer is a deployment engine (Ruby Gem) that enhances Capistrano with a set of useful automated deployment tasks. It favors convention over configuration, and it simplifies Rails Application Deployment with Capistrano.}
|
10
|
-
gem.email = "meskyanichi@gmail.com"
|
11
|
-
#gem.homepage = "http://github.com/meskyanichi/deployer"
|
12
|
-
gem.authors = ["Michael van Rooijen"]
|
13
|
-
gem.add_dependency "capistrano", ">= 2.5.13"
|
14
|
-
end
|
15
|
-
Jeweler::GemcutterTasks.new
|
16
|
-
rescue LoadError
|
17
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
-
end
|
19
|
-
|
20
|
-
require 'rake/testtask'
|
21
|
-
Rake::TestTask.new(:test) do |test|
|
22
|
-
test.libs << 'lib' << 'test'
|
23
|
-
test.pattern = 'test/**/test_*.rb'
|
24
|
-
test.verbose = true
|
25
|
-
end
|
26
|
-
|
27
|
-
begin
|
28
|
-
require 'rcov/rcovtask'
|
29
|
-
Rcov::RcovTask.new do |test|
|
30
|
-
test.libs << 'test'
|
31
|
-
test.pattern = 'test/**/test_*.rb'
|
32
|
-
test.verbose = true
|
33
|
-
end
|
34
|
-
rescue LoadError
|
35
|
-
task :rcov do
|
36
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
task :test => :check_dependencies
|
41
|
-
|
42
|
-
task :default => :test
|
43
|
-
|
44
|
-
require 'rake/rdoctask'
|
45
|
-
Rake::RDocTask.new do |rdoc|
|
46
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
-
|
48
|
-
rdoc.rdoc_dir = 'rdoc'
|
49
|
-
rdoc.title = "deployer #{version}"
|
50
|
-
rdoc.rdoc_files.include('README*')
|
51
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.1
|