if-vlad 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.
@@ -0,0 +1,4 @@
1
+ \#*#
2
+ \.\#*
3
+ pkg
4
+ *.gemspec
@@ -0,0 +1,14 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "if-vlad"
5
+ gemspec.summary = "Innovation Factory Specific Vlad Recipes"
6
+ gemspec.description = "Our deployment specific vlad recipes. We use them, perhaps they're useful for you too?"
7
+ gemspec.email = "dev@innovationfactory.eu"
8
+ gemspec.homepage = "http://github.com/innovationfactory/if-vlad"
9
+ gemspec.authors = ["Sam Aaron", "Sjoerd Andringa"]
10
+ gemspec.add_dependency 'vlad', '>= 2.0.0'
11
+ end
12
+ rescue LoadError
13
+ puts "Oops, Jeweler isn't available. Install it with: gem install jeweler"
14
+ end
data/Readme ADDED
@@ -0,0 +1,49 @@
1
+ _ __ _ _
2
+ (_)/ _| | | | |
3
+ _| |_ ________ _| | __ _ __| |
4
+ | | _|______\ \ / / |/ _` |/ _` |
5
+ | | | \ V /| | (_| | (_| |
6
+ |_|_| \_/ |_|\__,_|\__,_|
7
+
8
+ - Innovation Factory Specific Vlad Recipes.
9
+
10
+ To get up and running with this, first up add the following to your project's Rakefile:
11
+ require 'if-vlad'
12
+
13
+ Then make sure that you have a config/deploy.rb file that might look like the following:
14
+
15
+ set :user, "deploy"
16
+ set :application, "people"
17
+ set :repository, "git@github.com:innovationfactory/people.git"
18
+ set :revision, "origin/deploy"
19
+ set :web_command, "sudo apache2ctl"
20
+
21
+ task :acceptance do |t|
22
+ set :environment, t.name
23
+ set :migrate_args, "RAILS_ENV=#{environment}"
24
+ set :deploy_host, "#{application}.#{environment}.innovationfactory.net"
25
+ set :domain, "#{user}@#{deploy_host}"
26
+ set :deploy_to, "/var/www/deploy/www/#{deploy_host}"
27
+ end
28
+
29
+ namespace :vlad do
30
+ namespace :if do
31
+
32
+ desc "Perform a full deploy."
33
+ task :deploy => %w[
34
+ vlad:if:maintenance:off
35
+ vlad:if:update
36
+ vlad:if:symlink:shared
37
+ vlad:if:touch:shared_log
38
+ vlad:if:gems:install
39
+ vlad:if:migrate
40
+ vlad:if:update_crontab
41
+ vlad:if:ts:full_reboot
42
+ vlad:if:start
43
+ vlad:if:cleanup
44
+ vlad:if:maintenance:on
45
+ ]
46
+
47
+ end
48
+ end
49
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,24 @@
1
+ require 'vlad'
2
+
3
+ #require custom IF recipes
4
+ require 'if-vlad/update'
5
+ require 'if-vlad/maintenance'
6
+ require 'if-vlad/gems'
7
+ require 'if-vlad/thinking_sphinx'
8
+ require 'if-vlad/migrate'
9
+ require 'if-vlad/cleanup'
10
+ require 'if-vlad/start_stop'
11
+ require 'if-vlad/symlink'
12
+ require 'if-vlad/touch'
13
+ require 'if-vlad/update_crontab'
14
+ require 'if-vlad/git_with_submodule_support'
15
+
16
+
17
+ #require deploy script
18
+ begin
19
+ Kernel.load 'config/deploy.rb'
20
+ rescue LoadError
21
+ puts "Couldn't find config/deploy.rb, perhaps you might consider making one?"
22
+ end
23
+
24
+ Kernel.load "config/deploy_#{ENV['to']}.rb" if ENV['to']
@@ -0,0 +1,22 @@
1
+ namespace :vlad do
2
+ namespace :if do
3
+ desc "Clean up old releases. By default, the last 5 releases are kept on
4
+ each server (though you can change this with the keep_releases variable).
5
+ All other deployed revisions are removed from the servers.".cleanup
6
+
7
+ remote_task :cleanup do
8
+ max = keep_releases
9
+ if releases.length <= max then
10
+ puts "no old releases to clean up #{releases.length} <= #{max}"
11
+ else
12
+ puts "keeping #{max} of #{releases.length} deployed releases"
13
+
14
+ directories = (releases - releases.last(max)).map { |release|
15
+ File.join(releases_path, release)
16
+ }.join(" ")
17
+
18
+ run "rm -rf #{directories}"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ namespace :vlad do
2
+ namespace :if do
3
+ namespace :gems do
4
+ desc "Install required gems."
5
+ remote_task :install, :roles => :app do
6
+ run "cd #{current_path} && sudo rake gems:install RAILS_ENV=#{environment}"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,56 @@
1
+ class Vlad::GitWithSubmoduleSupport
2
+ #based entirely upon the vlad-git gem.
3
+
4
+ VERSION = "1.0"
5
+ set :source, Vlad::GitWithSubmoduleSupport.new
6
+ set :git_cmd, "git"
7
+
8
+ ##
9
+ # Returns the command that will check out +revision+ from the
10
+ # repository into directory +destination+. +revision+ can be any
11
+ # SHA1 or equivalent (e.g. branch, tag, etc...)def etc...)
12
+ # Also inits and updates submodules.
13
+
14
+ def checkout(revision, destination)
15
+ destination = File.join(destination, 'repo')
16
+ revision = 'HEAD' if revision =~ /head/i
17
+
18
+ [ "rm -rf #{destination}",
19
+ "#{git_cmd} clone #{repository} #{destination}",
20
+ "cd #{destination}",
21
+ "#{git_cmd} checkout -f -b deployed-#{revision} #{revision}",
22
+ "git submodule -q update --init",
23
+ "cd -"
24
+ ].join(" && ")
25
+ end
26
+
27
+ ##
28
+ # Returns the command that will export +revision+ from the current directory
29
+ # into the directory +destination+.
30
+ # Expects to be run from +scm_path+ after Vlad::Git#checkout
31
+ # Also checks out submodules.
32
+
33
+ def export(revision, destination)
34
+ revision = 'HEAD' if revision =~ /head/i
35
+ revision = "deployed-#{revision}"
36
+
37
+ [ "mkdir -p #{destination}",
38
+ "cd repo",
39
+ "git-archive-all.sh #{application}.tar",
40
+ "cat #{application}.tar | (cd #{destination} && tar xf -)",
41
+ "rm -f #{application}.tar",
42
+ "cd -",
43
+ "cd .."
44
+ ].join(" && ")
45
+ end
46
+
47
+ ##
48
+ # Returns a command that maps human-friendly revision identifier +revision+
49
+ # into a git SHA1.
50
+
51
+ def revision(revision)
52
+ revision = 'HEAD' if revision =~ /head/i
53
+
54
+ "`#{git_cmd} rev-parse #{revision}`"
55
+ end
56
+ end
@@ -0,0 +1,15 @@
1
+ namespace :vlad do
2
+ namespace :if do
3
+ namespace :maintenance do
4
+ desc "Put up a 503 page for maintenance."
5
+ remote_task :on, :roles => :app do
6
+ run "touch #{current_path}/tmp/stop.txt"
7
+ end
8
+
9
+ desc "Remove 503 page (after maintenance)."
10
+ remote_task :off, :roles => :app do
11
+ run "rm -f #{current_path}/tmp/stop.txt"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ namespace :vlad do
2
+ namespace :if do
3
+ desc "Run the migrate rake task for the the app. By default this is run in
4
+ the latest app directory. You can run migrations for the current app
5
+ directory by setting :migrate_target to :current. Additional environment
6
+ variables can be passed to rake via the migrate_env variable.".cleanup
7
+
8
+ # No application files are on the DB machine, also migrations should only be
9
+ # run once.
10
+ remote_task :migrate, :roles => :app do
11
+ break unless target_host == Rake::RemoteTask.hosts_for(:app).first
12
+
13
+ directory = case migrate_target.to_sym
14
+ when :current then current_path
15
+ when :latest then current_release
16
+ else raise ArgumentError, "unknown migration target #{migrate_target.inspect}"
17
+ end
18
+
19
+ run "cd #{directory}; #{rake_cmd} RAILS_ENV=#{rails_env} db:migrate #{migrate_args}"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ namespace :vlad do
2
+ namespace :if do
3
+ set :web_command, "apachectl"
4
+
5
+ desc "(Re)Start the web servers"
6
+ remote_task :start_apache, :roles => :web do
7
+ run "#{web_command} restart"
8
+ end
9
+
10
+ desc "Stop the web servers"
11
+ remote_task :stop_apache, :roles => :web do
12
+ run "#{web_command} stop"
13
+ end
14
+
15
+ desc "(Re)Start the web and app servers"
16
+ remote_task :start do
17
+ Rake::Task['vlad:if:start_apache'].invoke
18
+ end
19
+
20
+ desc "Stop the web and app servers"
21
+ remote_task :stop do
22
+ Rake::Task['vlad:if:stop_apache'].invoke
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,11 @@
1
+ namespace :vlad do
2
+ namespace :if do
3
+ desc "Create symlinks from local app dir to system shared dir"
4
+ namespace :symlink do
5
+ desc "Symlinks shared directory."
6
+ remote_task :shared, :roles => :app do
7
+ run "rm -rf #{current_path}/shared && ln -s #{shared_path} #{current_path}/shared"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,41 @@
1
+ namespace :vlad do
2
+ namespace :if do
3
+ namespace :ts do
4
+ def run_ts_task(name)
5
+ run "cd #{current_path} && rake ts:#{name} RAILS_ENV=#{environment}"
6
+ end
7
+
8
+ desc "Reconfigure, reindex and restart Sphinx"
9
+ remote_task :full_reboot => %w[
10
+ ts:conf
11
+ ts:in
12
+ ts:run
13
+ ]
14
+
15
+ desc "Generate Sphinx configuration file."
16
+ remote_task :conf, :roles => :web do
17
+ run_ts_task :conf
18
+ end
19
+
20
+ desc "Rebuild Sphinx' index."
21
+ remote_task :in, :roles => :web do
22
+ run_ts_task :in
23
+ end
24
+
25
+ desc "Stop Sphinx."
26
+ remote_task :stop, :roles => :web do
27
+ run_ts_task :stop
28
+ end
29
+
30
+ desc "Start Sphinx."
31
+ remote_task :start, :roles => :web do
32
+ run_ts_task :start
33
+ end
34
+
35
+ desc "Stop Sphinx if running and then start it."
36
+ remote_task :run, :roles => :web do
37
+ run_ts_task :run
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,11 @@
1
+ namespace :vlad do
2
+ namespace :if do
3
+ namespace :touch do
4
+ desc "Touch the shared log to create a log file for this environment if one doesn't already exist"
5
+ remote_task :shared_log, :roles => :web do
6
+ run "cd #{current_path} && touch shared/log/#{environment}.log"
7
+ run "cd #{current_path} && touch shared/log/cron.log"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,29 @@
1
+ namespace :vlad do
2
+ namespace :if do
3
+ desc "Updates your application server to the latest revision. Syncs
4
+ a copy of the repository, exports it as the latest release, fixes
5
+ up your symlinks, symlinks the latest revision to current and logs
6
+ the update.".cleanup
7
+
8
+ remote_task :update, :roles => :app do
9
+ symlink = false
10
+ begin
11
+ run [ "cd #{scm_path}",
12
+ "#{source.checkout revision, scm_path}",
13
+ "#{source.export revision, release_path}",
14
+ "chmod -R g+w #{latest_release}",
15
+ ].join(" && ")
16
+
17
+ symlink = true
18
+ run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
19
+
20
+ run "echo #{Time.now} $USER #{revision} #{File.basename release_path} >> #{deploy_to}/revisions.log"
21
+ rescue => e
22
+ run "rm -f #{current_path} && ln -s #{previous_release} #{current_path}" if
23
+ symlink
24
+ run "rm -rf #{release_path}"
25
+ raise e
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ namespace :vlad do
2
+ namespace :if do
3
+ desc "Update the crontab for the app's whenever schedule (stored in ./configs/schedule.rb)"
4
+ remote_task :update_crontab, :roles => :web do
5
+ run "cd #{current_path} && whenever --update-crontab #{application} --set 'environment=#{environment}&cron_log=#{shared_path}/log/cron.log'"
6
+ end
7
+ end
8
+ end
9
+
10
+
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: if-vlad
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sam Aaron
8
+ - Sjoerd Andringa
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-11-04 00:00:00 +00:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: vlad
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 2.0.0
25
+ version:
26
+ description: Our deployment specific vlad recipes. We use them, perhaps they're useful for you too?
27
+ email: dev@innovationfactory.eu
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files: []
33
+
34
+ files:
35
+ - .gitignore
36
+ - Rakefile
37
+ - Readme
38
+ - VERSION
39
+ - lib/if-vlad.rb
40
+ - lib/if-vlad/cleanup.rb
41
+ - lib/if-vlad/gems.rb
42
+ - lib/if-vlad/git_with_submodule_support.rb
43
+ - lib/if-vlad/maintenance.rb
44
+ - lib/if-vlad/migrate.rb
45
+ - lib/if-vlad/start_stop.rb
46
+ - lib/if-vlad/symlink.rb
47
+ - lib/if-vlad/thinking_sphinx.rb
48
+ - lib/if-vlad/touch.rb
49
+ - lib/if-vlad/update.rb
50
+ - lib/if-vlad/update_crontab.rb
51
+ has_rdoc: true
52
+ homepage: http://github.com/innovationfactory/if-vlad
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options:
57
+ - --charset=UTF-8
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ version:
72
+ requirements: []
73
+
74
+ rubyforge_project:
75
+ rubygems_version: 1.3.5
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Innovation Factory Specific Vlad Recipes
79
+ test_files: []
80
+