capistrano-chocopoche 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +81 -0
- data/capistrano-chocopoche.gemspec +19 -0
- data/lib/capistrano-chocopoche/common.rb +16 -0
- data/lib/capistrano-chocopoche/files.rb +83 -0
- data/lib/capistrano-chocopoche/railsless-deploy.rb +91 -0
- metadata +67 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: 104eae3fd531c8505cdc096f0f8f393db8b4baa2
|
|
4
|
+
data.tar.gz: 57835b9a5b8d2afe3f83c02014a1e18231b76375
|
|
5
|
+
!binary "U0hBNTEy":
|
|
6
|
+
metadata.gz: f4d70fef6d3fe0b19b478c5c20a8f32cb74b4888076fd33a40c47542d5dc307a6d3a99e5a2cde30a652b770dce19f9e068a723d672a018bb799300d26b09dcea
|
|
7
|
+
data.tar.gz: 010cadc4fda76d0716b665b98912588d8a1fddcf88c0555b701884e612103f334ca4d682965a9a8870270d4df563c38a24da11ed27d08c359acd053b76139336
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Corentin Merot
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Capistrano chopoche's recipes
|
|
2
|
+
|
|
3
|
+
My capistrano poche contains:
|
|
4
|
+
|
|
5
|
+
- another railsless-deploy recipe
|
|
6
|
+
- a files utility to rsync directories
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
$ gem install capistrano-chocopoche
|
|
11
|
+
|
|
12
|
+
## Example of a Capfile
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
# Capistrao defaults
|
|
16
|
+
load 'deploy'
|
|
17
|
+
|
|
18
|
+
# Multistage - to be loaded before the railsless-deploy
|
|
19
|
+
require 'capistrano/ext/multistage'
|
|
20
|
+
|
|
21
|
+
# Rails inhibition
|
|
22
|
+
require 'capistrano-chocopoche/railsless-deploy'
|
|
23
|
+
|
|
24
|
+
# Rsync tasks
|
|
25
|
+
require 'capistrano-chocopoche/files'
|
|
26
|
+
|
|
27
|
+
# Base configuration
|
|
28
|
+
set :application, "my-project"
|
|
29
|
+
set :repository, "git@localhost:#{application}.git"
|
|
30
|
+
set :use_sudo, false
|
|
31
|
+
ssh_options[:forward_agent] = true
|
|
32
|
+
|
|
33
|
+
# Rsync + symlinks configuration
|
|
34
|
+
set :files_directories, [ 'public/upload' ]
|
|
35
|
+
set :files_symlinks, [ 'public/upload' ]
|
|
36
|
+
|
|
37
|
+
# Server config, won't be here in case of multistage
|
|
38
|
+
server 'localhost', :app, :web, :db, :primary => true
|
|
39
|
+
|
|
40
|
+
# # default settings
|
|
41
|
+
# set :files_tmp_dir, 'tmp/capistrano-chocopoche/files'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Railsless-deploy
|
|
45
|
+
|
|
46
|
+
This script requires the default capistrano tasks to be loaded, then it will:
|
|
47
|
+
|
|
48
|
+
- delete rails tasks: `migrate`, `migrations`, `cold`
|
|
49
|
+
- empty rails tasks (but keep it for hooks): `finalize_update`
|
|
50
|
+
- delete rails vars: `rails_env`
|
|
51
|
+
- empty rails vars: `shared_children`
|
|
52
|
+
- override the `deploy_to` var to:
|
|
53
|
+
|
|
54
|
+
- `/home/#{user}/apps/#{application}.#{stage}`
|
|
55
|
+
- or `/home/#{user}/apps/#{application}` if the multistage ext is not
|
|
56
|
+
loaded.
|
|
57
|
+
|
|
58
|
+
Therefore the multistage ext must be required before the railsless-deploy.
|
|
59
|
+
|
|
60
|
+
- override symlinks related tasks to use relative paths: create_symlink,
|
|
61
|
+
rollback:revision
|
|
62
|
+
|
|
63
|
+
The last one implements the atomic symlink as suggested in the
|
|
64
|
+
[issue #346](https://github.com/capistrano/capistrano/issues/346).
|
|
65
|
+
|
|
66
|
+
## Files
|
|
67
|
+
|
|
68
|
+
The **files:download** task will rsync files from the first web server in
|
|
69
|
+
`shared/your/directory` to a local temporary directory `tmp/capistrano-chocopoche/files/your/directory`.
|
|
70
|
+
|
|
71
|
+
The **files:upload** task will do the opposite of the **files:download** task.
|
|
72
|
+
|
|
73
|
+
The **files:create_symlinks** creates symlinks from the shared to the current.
|
|
74
|
+
The equivalent for the Capfile example:
|
|
75
|
+
|
|
76
|
+
$ mkdir -p #{current_path}/public
|
|
77
|
+
$ ln -fs #{shared_path}/public/upload #{current_path}/public
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT, see the license file.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# coding: 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 |spec|
|
|
6
|
+
spec.name = "capistrano-chocopoche"
|
|
7
|
+
spec.version = "0.0.1"
|
|
8
|
+
spec.authors = ["Corentin Merot"]
|
|
9
|
+
spec.email = ["cmerot@themarqueeblink.com"]
|
|
10
|
+
spec.description = %q{Capistrano recipes, with another railsless-deploy and a files utility.}
|
|
11
|
+
spec.summary = %q{Chocopoche's Capistrano recipes}
|
|
12
|
+
spec.homepage = "https://github.com/chocopoche/capistrano-chocopoche"
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
spec.files = `git ls-files`.split($/)
|
|
15
|
+
spec.require_paths = ["lib"]
|
|
16
|
+
|
|
17
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
|
18
|
+
end
|
|
19
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
|
2
|
+
Capistrano::Configuration.instance(:must_exist) :
|
|
3
|
+
Capistrano.configuration(:must_exist)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
configuration.load do
|
|
7
|
+
|
|
8
|
+
_cset :user, Etc.getlogin
|
|
9
|
+
|
|
10
|
+
# Used to create relative symlinks in deploy.create_symlink
|
|
11
|
+
def relative_path(from_str, to_str)
|
|
12
|
+
require 'pathname'
|
|
13
|
+
Pathname.new(to_str).relative_path_from(Pathname.new(from_str)).to_s
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Capistrano recipe to rsync files up and down.
|
|
2
|
+
#
|
|
3
|
+
# author: Corentin Merot
|
|
4
|
+
# real author: Michael Kessler aka netzpirat, see https://gist.github.com/111597
|
|
5
|
+
|
|
6
|
+
require 'fileutils'
|
|
7
|
+
require 'capistrano-chocopoche/common'
|
|
8
|
+
|
|
9
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
|
10
|
+
Capistrano::Configuration.instance(:must_exist) :
|
|
11
|
+
Capistrano.configuration(:must_exist)
|
|
12
|
+
|
|
13
|
+
configuration.load do
|
|
14
|
+
|
|
15
|
+
_cset :user, Etc.getlogin
|
|
16
|
+
_cset :files_directories, []
|
|
17
|
+
_cset :files_tmp_dir, 'tmp/capistrano-chocopoche/files'
|
|
18
|
+
|
|
19
|
+
namespace :files do
|
|
20
|
+
|
|
21
|
+
desc <<-DESC
|
|
22
|
+
Sync files from the first web server to the local temp directory. \
|
|
23
|
+
Files on the remote server must be somewhere in the shared directory.
|
|
24
|
+
DESC
|
|
25
|
+
task :download, :roles => :web, :only => { :primary => true }, :once => true do
|
|
26
|
+
|
|
27
|
+
host, port = host_and_port
|
|
28
|
+
|
|
29
|
+
Array(fetch(:files_directories, [])).each do |file_dir|
|
|
30
|
+
unless File.directory? "#{files_tmp_dir}/#{file_dir}"
|
|
31
|
+
logger.info "create temporary '#{files_tmp_dir}/#{file_dir}' folder"
|
|
32
|
+
FileUtils.mkdir_p "#{files_tmp_dir}/#{file_dir}"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
source = "#{shared_path}/#{file_dir}"
|
|
36
|
+
dest = File.dirname("#{files_tmp_dir}/#{file_dir}")
|
|
37
|
+
|
|
38
|
+
# Sync directory down
|
|
39
|
+
system "rsync --verbose --archive --compress --copy-links --delete --stats --rsh='ssh -p #{port}' #{user}@#{host}:#{source} #{dest}"
|
|
40
|
+
logger.info "sync files from #{host}:#{source} to #{dest} finished"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
desc <<-DESC
|
|
46
|
+
Sync files from the local temp directory to the first web server. \
|
|
47
|
+
Files on the remote server will be copied in the shared directory.
|
|
48
|
+
DESC
|
|
49
|
+
task :upload, :roles => :web, :only => { :primary => true }, :once => true do
|
|
50
|
+
|
|
51
|
+
host, port = host_and_port
|
|
52
|
+
Array(fetch(:files_directories, [])).each do |file_dir|
|
|
53
|
+
source = "#{files_tmp_dir}/#{file_dir}"
|
|
54
|
+
dest = File.dirname("#{shared_path}/#{file_dir}")
|
|
55
|
+
|
|
56
|
+
# Sync directory up
|
|
57
|
+
system "rsync --verbose --archive --compress --keep-dirlinks --delete --stats --rsh='ssh -p #{port}' #{source} #{user}@#{host}:#{dest}"
|
|
58
|
+
logger.info "sync files from #{source} to #{host}:#{dest} finished"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
desc <<-DESC
|
|
63
|
+
Creates :files_symlinks from the shared folder to the current one on the \
|
|
64
|
+
web servers
|
|
65
|
+
DESC
|
|
66
|
+
task :create_symlinks, :roles => [:web] do
|
|
67
|
+
symlinks = fetch(:files_symlinks)
|
|
68
|
+
cmds = symlinks.collect do | l |
|
|
69
|
+
parent = File.dirname("#{current_path}/#{l}")
|
|
70
|
+
"mkdir -p #{parent} && ln -fs #{shared_path}/#{l} #{current_path}/#{l}"
|
|
71
|
+
end
|
|
72
|
+
run cmds.join(' && ')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
#
|
|
76
|
+
# Returns the actual host name to sync and port
|
|
77
|
+
#
|
|
78
|
+
def host_and_port
|
|
79
|
+
return roles[:web].servers.first.host, ssh_options[:port] || roles[:web].servers.first.port || 22
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require 'etc'
|
|
2
|
+
require 'capistrano-chocopoche/common'
|
|
3
|
+
|
|
4
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
|
5
|
+
Capistrano::Configuration.instance(:must_exist) :
|
|
6
|
+
Capistrano.configuration(:must_exist)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
configuration.load do
|
|
10
|
+
|
|
11
|
+
# Remove rails specific tasks
|
|
12
|
+
deploy.tasks.delete(:migrate)
|
|
13
|
+
deploy.tasks.delete(:migrations)
|
|
14
|
+
deploy.tasks.delete(:cold)
|
|
15
|
+
|
|
16
|
+
# Remove rails specific vars
|
|
17
|
+
unset :rails_env
|
|
18
|
+
|
|
19
|
+
# Override `deploy to` to a more common path
|
|
20
|
+
if exists?(:stages)
|
|
21
|
+
logger.important "YYYYYYYYY"
|
|
22
|
+
set(:deploy_to) { "/home/#{user}/apps/#{application}.#{stage}" }
|
|
23
|
+
else
|
|
24
|
+
logger.important "NOOOOOOOO"
|
|
25
|
+
set(:deploy_to) { "/home/#{user}/apps/#{application}" }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Remove rails specific shared children
|
|
29
|
+
# set :shared_children, []
|
|
30
|
+
|
|
31
|
+
namespace :deploy do
|
|
32
|
+
|
|
33
|
+
desc <<-DESC
|
|
34
|
+
Updates the symlink to the most recently deployed version. Capistrano works \
|
|
35
|
+
by putting each new release of your application in its own directory. When \
|
|
36
|
+
you deploy a new version, this task's job is to update the `current' symlink \
|
|
37
|
+
to point at the new version. You will rarely need to call this task \
|
|
38
|
+
directly; instead, use the `deploy' task (which performs a complete \
|
|
39
|
+
deploy, including `restart') or the 'update' task (which does everything \
|
|
40
|
+
except `restart').
|
|
41
|
+
DESC
|
|
42
|
+
task :create_symlink, :except => { :no_release => true } do
|
|
43
|
+
on_rollback do
|
|
44
|
+
if previous_release
|
|
45
|
+
previous_release_relative = relative_path(deploy_to, previous_release)
|
|
46
|
+
run "ln -s #{previous_release_relative} #{current_path}.tmp && mv -f #{current_path}.tmp #{current_path}"
|
|
47
|
+
else
|
|
48
|
+
logger.important "no previous release to rollback to, rollback of symlink skipped"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
latest_release_relative = relative_path(deploy_to,latest_release)
|
|
52
|
+
run "ln -s #{latest_release_relative} #{current_path}.tmp && mv -f #{current_path}.tmp #{current_path}"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
desc <<-DESC
|
|
56
|
+
[internal] Touches up the released code. This is called by update_code \
|
|
57
|
+
after the basic deploy finishes. It assumes a Rails project was deployed, \
|
|
58
|
+
so if you are deploying something else, you may want to override this \
|
|
59
|
+
task with your own environment's requirements.
|
|
60
|
+
|
|
61
|
+
This task will make the release group-writable (if the :group_writable \
|
|
62
|
+
variable is set to true, which is the default). It will then set up \
|
|
63
|
+
symlinks to the shared directory for the log, system, and tmp/pids \
|
|
64
|
+
directories, and will lastly touch all assets in public/images, \
|
|
65
|
+
public/stylesheets, and public/javascripts so that the times are \
|
|
66
|
+
consistent (so that asset timestamping works). This touch process \
|
|
67
|
+
is only carried out if the :normalize_asset_timestamps variable is \
|
|
68
|
+
set to true, which is the default The asset directories can be overridden \
|
|
69
|
+
using the :public_children variable.
|
|
70
|
+
DESC
|
|
71
|
+
task :finalize_update, :except => { :no_release => true } do
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
namespace :rollback do
|
|
77
|
+
desc <<-DESC
|
|
78
|
+
[internal] Points the current symlink at the previous revision.
|
|
79
|
+
This is called by the rollback sequence, and should rarely (if
|
|
80
|
+
ever) need to be called directly.
|
|
81
|
+
DESC
|
|
82
|
+
task :revision, :except => { :no_release => true } do
|
|
83
|
+
if previous_release
|
|
84
|
+
previous_release_relative = relative_path(deploy_to, previous_release)
|
|
85
|
+
run "ln -s #{previous_release_relative} #{current_path}.tmp && mv -f #{current_path}.tmp #{current_path}"
|
|
86
|
+
else
|
|
87
|
+
abort "could not rollback the code because there is no prior release"
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: capistrano-chocopoche
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Corentin Merot
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2013-04-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.3'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.3'
|
|
27
|
+
description: Capistrano recipes, with another railsless-deploy and a files utility.
|
|
28
|
+
email:
|
|
29
|
+
- cmerot@themarqueeblink.com
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- .gitignore
|
|
35
|
+
- Gemfile
|
|
36
|
+
- LICENSE.txt
|
|
37
|
+
- README.md
|
|
38
|
+
- capistrano-chocopoche.gemspec
|
|
39
|
+
- lib/capistrano-chocopoche/common.rb
|
|
40
|
+
- lib/capistrano-chocopoche/files.rb
|
|
41
|
+
- lib/capistrano-chocopoche/railsless-deploy.rb
|
|
42
|
+
homepage: https://github.com/chocopoche/capistrano-chocopoche
|
|
43
|
+
licenses:
|
|
44
|
+
- MIT
|
|
45
|
+
metadata: {}
|
|
46
|
+
post_install_message:
|
|
47
|
+
rdoc_options: []
|
|
48
|
+
require_paths:
|
|
49
|
+
- lib
|
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ! '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ! '>='
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0'
|
|
60
|
+
requirements: []
|
|
61
|
+
rubyforge_project:
|
|
62
|
+
rubygems_version: 2.0.3
|
|
63
|
+
signing_key:
|
|
64
|
+
specification_version: 4
|
|
65
|
+
summary: Chocopoche's Capistrano recipes
|
|
66
|
+
test_files: []
|
|
67
|
+
has_rdoc:
|