youthtree-capistrano 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.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # YouthTree Capistrano #
2
+
3
+ A set of capistrano recipes to use for deploying YT apps. Out of the box, does:
4
+
5
+ * RVM
6
+ * Bundler
7
+ * Unicorn
8
+ * YouthTree Settings
9
+ * Compass
10
+ * Barista
11
+ * Jammit
12
+ * Symlinking Uploads
13
+
14
+ ## Contributing ##
15
+
16
+ We encourage all community contributions. Keeping this in mind, please follow these general guidelines when contributing:
17
+
18
+ * Fork the project
19
+ * Create a topic branch for what you’re working on (git checkout -b awesome_feature)
20
+ * Commit away, push that up (git push your\_remote awesome\_feature)
21
+ * Create a new GitHub Issue with the commit, asking for review. Alternatively, send a pull request with details of what you added.
22
+ * Once it’s accepted, if you want access to the core repository feel free to ask! Otherwise, you can continue to hack away in your own fork.
23
+
24
+ Other than that, our guidelines very closely match the GemCutter guidelines [here](http://wiki.github.com/qrush/gemcutter/contribution-guidelines).
25
+
26
+ (Thanks to [GemCutter](http://wiki.github.com/qrush/gemcutter/) for the contribution guide)
27
+
28
+ ## License ##
29
+
30
+ All code is licensed under the New BSD License and is copyright YouthTree. Please keep this
31
+ in mind when contributing.
32
+
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ $:.unshift "lib"
5
+ require 'youthtree-capistrano'
6
+
7
+ begin
8
+ require 'jeweler'
9
+ Jeweler::Tasks.new do |gem|
10
+ gem.name = "youthtree-capistrano"
11
+ gem.summary = "Capistrano tasks used for common Youth Tree deployments."
12
+ gem.description = "Capistrano tasks used for common Youth Tree deployments."
13
+ gem.email = "sutto@sutto.net"
14
+ gem.homepage = "http://github.com/YouthTree/youthtree-capistrano"
15
+ gem.version = YouthTree::Capistrano::VERSION
16
+ gem.authors = ["Darcy Laycock"]
17
+ gem.add_dependency "rvm", "~> 1.0"
18
+ gem.add_dependency "bundler", "~> 1.0"
19
+ gem.add_dependency "capistrano"
20
+ end
21
+ Jeweler::GemcutterTasks.new
22
+ rescue LoadError
23
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
24
+ end
25
+
@@ -0,0 +1,24 @@
1
+ module YouthTree
2
+ module Capistrano
3
+ VERSION = "0.0.1".freeze
4
+
5
+ def self.load(&blk)
6
+ ::Capistrano::Configuration.instance(:must_exist).load(&blk)
7
+ end
8
+
9
+ def self.load_recipe!(*names)
10
+ names.flatten.each { |name| require "youthtree/recipes/#{name}" }
11
+ end
12
+
13
+ def self.load_named(name, &blk)
14
+ load { load(&blk) unless disabled?(name) }
15
+ end
16
+
17
+ def self.load_all!
18
+ load_recipe! %w(base git bundler settings db unicorn compass barista jammit uploads)
19
+ load { load 'deploy' }
20
+ load_recipe! 'deploy_hooks'
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ YouthTree::Capistrano.load do
2
+ namespace :barista do
3
+
4
+ desc "Forces barista to compile the current coffeescripts"
5
+ task :update do
6
+ bundle_exec "rake barista:brew"
7
+ end
8
+
9
+ end
10
+
11
+ after 'deploy:update_code', 'barista:update'
12
+
13
+ end
@@ -0,0 +1,43 @@
1
+ YouthTree::Capistrano.load do
2
+
3
+ def disabled?(feature_name)
4
+ exists?(feature_name) && send(feature_name) == false
5
+ end
6
+
7
+ def yt_cset(name, *args, &block)
8
+ set(name, *args, &block) unless exists?(name)
9
+ end
10
+
11
+ def host_for_env(env, host)
12
+ server_hosts[env.to_s] = host.to_s
13
+ end
14
+
15
+ def bundle_exec(command)
16
+ run "cd '#{latest_release}' && RAILS_ENV='#{rails_env}' bundle exec #{command}"
17
+ end
18
+
19
+ def symlink_config(shared, current)
20
+ from, to = "#{shared_path}/#{shared}", "#{latest_release}/#{current}"
21
+ run "rm -rf '#{to}' && ln -s '#{from}' '#{to}'"
22
+ end
23
+
24
+ yt_cset :rails_env, "staging"
25
+ yt_cset :use_sudo, false
26
+ yt_cset :keep_releases, 10
27
+
28
+ yt_cset(:application) { raise "Please Ensure you set the application name." }
29
+ yt_cset(:user) { application }
30
+ yt_cset(:runner) { user }
31
+ yt_cset(:group) { user }
32
+ yt_cset(:deploy_to) { "/opt/#{application}/#{rails_env}" }
33
+
34
+ yt_cset :server_hosts, Hash.new
35
+
36
+ role(:web) { server_hosts[rails_env] }
37
+ role(:app) { server_hosts[rails_env] }
38
+ role(:db, :primary => true) { server_hosts[rails_env] }
39
+
40
+ host_for_env :staging, "dracorex.youthtree.org.au"
41
+ host_for_env :production, "dryptosaurus.youthtree.org.au"
42
+
43
+ end
@@ -0,0 +1,3 @@
1
+ YouthTree::Capistrano.load do
2
+ require 'bundler/capistrano'
3
+ end
@@ -0,0 +1,14 @@
1
+ YouthTree::Capistrano.load do
2
+
3
+ namespace :compass do
4
+
5
+ desc "Forces compass to compile the current stylesheets"
6
+ task :update do
7
+ bundle_exec "compass compile . --force"
8
+ end
9
+
10
+ end
11
+
12
+ after 'deploy:update_code', 'compass:update'
13
+
14
+ end
@@ -0,0 +1,23 @@
1
+ YouthTree::Capistrano.load do
2
+
3
+ yt_cset :database_shared_config, 'database.yml'
4
+ yt_cset :database_latest_config, 'config/database.yml'
5
+
6
+ namespace :database do
7
+
8
+ desc "Create an empty db config"
9
+ task :setup do
10
+ run "touch '#{shared_path}/#{database_shared_config}'"
11
+ end
12
+
13
+ desc "Symlinks the database.yml into place"
14
+ task :symlink do
15
+ symlink_config database_shared_config, database_latest_config
16
+ end
17
+
18
+ end
19
+
20
+ after 'deploy:setup', 'database:setup'
21
+ after 'deploy:update_code', 'database:symlink'
22
+
23
+ end
@@ -0,0 +1,20 @@
1
+ YouthTree::Capistrano.load do
2
+
3
+ namespace :deploy do
4
+ desc "Call unicorn.start"
5
+ task :start, :roles => :app do
6
+ unicorn.start
7
+ end
8
+
9
+ desc "Call unicorn.stop"
10
+ task :stop, :roles => :app do
11
+ unicorn.stop
12
+ end
13
+
14
+ desc "Call unicorn.restart"
15
+ task :restart, :roles => :app, :except => { :no_release => true } do
16
+ unicorn.restart
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,5 @@
1
+ YouthTree::Capistrano.load do
2
+ yt_cset :scm, :git
3
+ yt_cset(:repository_name) { application }
4
+ yt_cset(:repository) { "git://github.com/YouthTree/#{repository_name}.git" }
5
+ end
@@ -0,0 +1,14 @@
1
+ YouthTree::Capistrano.load do
2
+
3
+ namespace :jammit do
4
+
5
+ desc "Forces jammit to compress / package everything"
6
+ task :update do
7
+ bundle_exec "jammit -f"
8
+ end
9
+
10
+ end
11
+
12
+ after 'deploy:update_code', 'jammit:update'
13
+
14
+ end
@@ -0,0 +1,5 @@
1
+ YouthTree::Capistrano.load do
2
+ require 'rvm/capistrano'
3
+ yt_cset(:rvm_default_ruby) { "ree" }
4
+ yt_cset(:rvm_ruby_string) { "#{rvm_default_ruby}@#{}" }
5
+ end
@@ -0,0 +1,23 @@
1
+ YouthTree::Capistrano.load do
2
+
3
+ yt_cset :settings_shared_config, 'settings.yml'
4
+ yt_cset :settings_latest_config, 'config/settings.yml'
5
+
6
+ namespace :settings do
7
+
8
+ desc "Create an empty db config"
9
+ task :setup do
10
+ run "touch '#{shared_path}/#{settings_shared_config}'"
11
+ end
12
+
13
+ desc "Symlinks the settings.yml into place"
14
+ task :symlink do
15
+ symlink_config settings_shared_config, settings_latest_config
16
+ end
17
+
18
+ end
19
+
20
+ after 'deploy:setup', 'settings:setup'
21
+ after 'deploy:update_code', 'settings:symlink'
22
+
23
+ end
@@ -0,0 +1,44 @@
1
+ YouthTree::Capistrano.load do
2
+
3
+ yt_cset :unicorn_shared_config, 'unicorn.rb'
4
+ yt_cset :unicorn_latest_config, 'config/unicorn.rb'
5
+ yt_cset :unicorn_pid_file, 'tmp/pids'
6
+
7
+ namespace :unicorn do
8
+
9
+ def signal!(signal)
10
+ pid_file = "tmp/pids/unicorn.pid"
11
+ run "cd '#{current_path}' && [ -f #{pid_file} ] && kill -#{signal} `cat #{pid_file}`"
12
+ end
13
+
14
+ desc "Creates a blank unicorn config file"
15
+ task :setup, :roles => :app do
16
+ run "touch '#{shared_path}/#{unicorn_shared_config}'"
17
+ end
18
+
19
+ desc "Symlinks the unicorn config into place"
20
+ task :symlink, :roles => :app do
21
+ symlink_config unicorn_shared_config, unicorn_latest_config
22
+ end
23
+
24
+ desc "Starts the unicorn app server"
25
+ task :start, :roles => :app do
26
+ run "cd '#{current_path}' && bundle exec unicorn_rails -D -E #{rails_env} -c '#{current_path}/#{unicorn_latest_config}'"
27
+ end
28
+
29
+ desc "Stops the unicorn app server"
30
+ task :stop, :roles => :app do
31
+ signal! :QUIT
32
+ end
33
+
34
+ desc "Restarts unicorn (via a signal)"
35
+ task :restart, :roles => :app do
36
+ signal! :USR2
37
+ end
38
+
39
+ end
40
+
41
+ after 'deploy:setup', 'unicorn:setup'
42
+ after 'deploy:update_code', 'unicorn:symlink'
43
+
44
+ end
@@ -0,0 +1,23 @@
1
+ YouthTree::Capistrano.load_named(:uploads) do
2
+
3
+ yt_cset :uploads_shared, 'uploads'
4
+ yt_cset :uploads_latest, 'public/uploads'
5
+
6
+ namespace :uploads do
7
+
8
+ desc "Creates an uploads directory in the shared path"
9
+ task :setup do
10
+ run "mkdir -p '#{shared_path}/#{uploads_shared}'"
11
+ end
12
+
13
+ desc "Symlinks the uploads folder into place"
14
+ task :symlink do
15
+ symlink_config uploads_shared, uploads_latest
16
+ end
17
+
18
+ end
19
+
20
+ after 'deploy:setup', 'uploads:setup'
21
+ after 'deploy:update_code', 'uploads:symlink'
22
+
23
+ end
@@ -0,0 +1,2 @@
1
+ require 'youthtree/capistrano'
2
+ YouthTree::Capistrano.load_all! if defined?(Capistrano)
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: youthtree-capistrano
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Darcy Laycock
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-24 00:00:00 +08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rvm
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 1
32
+ - 0
33
+ version: "1.0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 15
45
+ segments:
46
+ - 1
47
+ - 0
48
+ version: "1.0"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: capistrano
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ description: Capistrano tasks used for common Youth Tree deployments.
66
+ email: sutto@sutto.net
67
+ executables: []
68
+
69
+ extensions: []
70
+
71
+ extra_rdoc_files:
72
+ - README.md
73
+ files:
74
+ - README.md
75
+ - Rakefile
76
+ - lib/youthtree-capistrano.rb
77
+ - lib/youthtree/capistrano.rb
78
+ - lib/youthtree/recipes/barista.rb
79
+ - lib/youthtree/recipes/base.rb
80
+ - lib/youthtree/recipes/bundler.rb
81
+ - lib/youthtree/recipes/compass.rb
82
+ - lib/youthtree/recipes/db.rb
83
+ - lib/youthtree/recipes/deploy_hooks.rb
84
+ - lib/youthtree/recipes/git.rb
85
+ - lib/youthtree/recipes/jammit.rb
86
+ - lib/youthtree/recipes/rvm.rb
87
+ - lib/youthtree/recipes/settings.rb
88
+ - lib/youthtree/recipes/unicorn.rb
89
+ - lib/youthtree/recipes/uploads.rb
90
+ has_rdoc: true
91
+ homepage: http://github.com/YouthTree/youthtree-capistrano
92
+ licenses: []
93
+
94
+ post_install_message:
95
+ rdoc_options:
96
+ - --charset=UTF-8
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ hash: 3
105
+ segments:
106
+ - 0
107
+ version: "0"
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
116
+ version: "0"
117
+ requirements: []
118
+
119
+ rubyforge_project:
120
+ rubygems_version: 1.3.7
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Capistrano tasks used for common Youth Tree deployments.
124
+ test_files: []
125
+