factorylabs-fdlcap 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/fdlcap.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{fdlcap}
5
- s.version = "0.1.0"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Factory Design Labs"]
@@ -27,27 +27,30 @@ Gem::Specification.new do |s|
27
27
  "features/step_definitions/fdlcap_steps.rb",
28
28
  "features/support/env.rb",
29
29
  "lib/fdlcap.rb",
30
- "lib/fdlcap/autotagger.rb",
31
- "lib/fdlcap/craken.rb",
32
- "lib/fdlcap/database.rb",
33
- "lib/fdlcap/delayed_job.rb",
34
- "lib/fdlcap/deploy.rb",
35
- "lib/fdlcap/geminstaller.rb",
36
- "lib/fdlcap/newrelic.rb",
37
- "lib/fdlcap/nginx.rb",
38
- "lib/fdlcap/performance.rb",
39
- "lib/fdlcap/rake.rb",
30
+ "lib/fdlcap/defaults.rb",
31
+ "lib/fdlcap/extensions/configuration.rb",
32
+ "lib/fdlcap/extensions/recipe_definition.rb",
40
33
  "lib/fdlcap/recipes.rb",
41
- "lib/fdlcap/rsync.rb",
42
- "lib/fdlcap/sass.rb",
43
- "lib/fdlcap/slice.rb",
44
- "lib/fdlcap/ssh.rb",
45
- "lib/fdlcap/symlinks.rb",
34
+ "lib/fdlcap/recipes/autotagger.rb",
35
+ "lib/fdlcap/recipes/craken.rb",
36
+ "lib/fdlcap/recipes/database.rb",
37
+ "lib/fdlcap/recipes/delayed_job.rb",
38
+ "lib/fdlcap/recipes/deploy.rb",
39
+ "lib/fdlcap/recipes/geminstaller.rb",
40
+ "lib/fdlcap/recipes/newrelic.rb",
41
+ "lib/fdlcap/recipes/nginx.rb",
42
+ "lib/fdlcap/recipes/performance.rb",
43
+ "lib/fdlcap/recipes/rake.rb",
44
+ "lib/fdlcap/recipes/rsync.rb",
45
+ "lib/fdlcap/recipes/sass.rb",
46
+ "lib/fdlcap/recipes/slice.rb",
47
+ "lib/fdlcap/recipes/ssh.rb",
48
+ "lib/fdlcap/recipes/symlinks.rb",
49
+ "lib/fdlcap/recipes/thin.rb",
50
+ "lib/fdlcap/recipes/thinking_sphinx.rb",
46
51
  "lib/fdlcap/templates/nginx.auth.conf.erb",
47
52
  "lib/fdlcap/templates/nginx.conf.erb",
48
53
  "lib/fdlcap/templates/nginx.vhost.conf.erb",
49
- "lib/fdlcap/thin.rb",
50
- "lib/fdlcap/thinking_sphinx.rb",
51
54
  "test/fdlcap_test.rb",
52
55
  "test/test_helper.rb"
53
56
  ]
@@ -0,0 +1,12 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ # Set up default stages for capistano-ext-multistage
4
+ unless exists?(:stages)
5
+ set :stages, [ :staging, :production ]
6
+ end
7
+
8
+ unless exists?(:default_stage)
9
+ set :default_stage, :staging
10
+ end
11
+
12
+ end
@@ -0,0 +1,34 @@
1
+ class Capistrano::Configuration
2
+
3
+ ##
4
+ # Print an informative message with asterisks.
5
+
6
+ def inform(message)
7
+ puts "#{'*' * (message.length + 4)}"
8
+ puts "* #{message} *"
9
+ puts "#{'*' * (message.length + 4)}"
10
+ end
11
+
12
+ ##
13
+ # Read a file and evaluate it as an ERB template.
14
+ # Path is relative to this file's directory.
15
+
16
+ def render_erb_template(filename)
17
+ template = File.read(filename)
18
+ result = ERB.new(template).result(binding)
19
+ end
20
+
21
+ ##
22
+ # Run a command and return the result as a string.
23
+ #
24
+ # TODO May not work properly on multiple servers.
25
+
26
+ def run_and_return(cmd)
27
+ output = []
28
+ run cmd do |ch, st, data|
29
+ output << data
30
+ end
31
+ return output.to_s
32
+ end
33
+
34
+ end
@@ -0,0 +1,14 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ set :fdlcap_recipes, {}
4
+
5
+ def define_recipe(name,&block)
6
+ recipes = fetch(:fdlcap_recipes)
7
+ recipes[name] = block
8
+ end
9
+
10
+ def use_recipe(recipe)
11
+ fetch(:fdlcap_recipes)[recipe].call
12
+ end
13
+
14
+ end
@@ -1,24 +1,15 @@
1
+ # Pull in cap extensions
2
+ require 'fdlcap/extensions/configuration'
3
+ require 'fdlcap/extensions/recipe_definition'
4
+
1
5
  # Set up configuration defaults
2
- Capistrano::Configuration.instance(:must_exist).load do
3
- unless exists?(:stages)
4
- set :stages, [ :staging, :production ]
5
- end
6
-
7
- unless exists?(:use_release_tagger) && exists?(:autotagger_stages)
8
- set :autotagger_stages, [ :ci, :staging, :production ]
9
- end
10
-
11
- unless exists?(:default_stage)
12
- set :default_stage, :staging
13
- end
14
- end
6
+ require 'fdlcap/defaults'
15
7
 
16
- # Load fdlcap dependencies
17
- require 'release_tagger'
8
+ # Load external fdlcap dependencies
18
9
  require 'capistrano/ext/multistage'
19
10
  require 'eycap/recipes'
20
11
 
21
- # Load up custom recipes and callbacks
12
+ # Load up custom recipe chunks
22
13
  require 'fdlcap/recipes/autotagger'
23
14
  require 'fdlcap/recipes/craken'
24
15
  require 'fdlcap/recipes/database'
@@ -26,10 +17,13 @@ require 'fdlcap/recipes/delayed_job'
26
17
  require 'fdlcap/recipes/deploy'
27
18
  require 'fdlcap/recipes/geminstaller'
28
19
  require 'fdlcap/recipes/newrelic'
20
+ require 'fdlcap/recipes/nginx'
29
21
  require 'fdlcap/recipes/performance'
30
22
  require 'fdlcap/recipes/rake'
31
23
  require 'fdlcap/recipes/rsync'
32
24
  require 'fdlcap/recipes/sass'
33
- require 'fdlcap/recipes/ssh'
34
25
  require 'fdlcap/recipes/slice'
26
+ require 'fdlcap/recipes/ssh'
27
+ require 'fdlcap/recipes/symlinks'
28
+ require 'fdlcap/recipes/thin'
35
29
  require 'fdlcap/recipes/thinking_sphinx'
@@ -1,6 +1,12 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
- # Run autotagger to get the right release
3
- if exists?(:use_release_tagger)
2
+ define_recipe :release_tagger do
3
+ # Set up some default stages
4
+ set :autotagger_stages, [ :ci, :staging, :production ] unless exists?(:autotagger_stages)
5
+
6
+ # This needs to be loaded after the stages are set up
7
+ require 'release_tagger'
8
+
9
+ # Run release tagger to get the right release for the deploy
4
10
  before "deploy:update_code", "release_tagger:set_branch"
5
11
  before "deploy:cleanup", "release_tagger:create_tag"
6
12
  before "deploy:cleanup", "release_tagger:write_tag_to_shared"
@@ -0,0 +1,5 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ define_recipe :craken do
3
+ after "deploy:update", "craken:install"
4
+ end
5
+ end
File without changes
@@ -17,7 +17,7 @@ Capistrano::Configuration.instance(:must_exist).load do
17
17
  end
18
18
 
19
19
  # Clean up old releases
20
- if exists?(:perform_cleanup)
20
+ define_recipe :perform_cleanup do
21
21
  after "deploy", "deploy:cleanup"
22
22
  after "deploy:migrations" , "deploy:cleanup"
23
23
  after "deploy:long" , "deploy:cleanup"
@@ -0,0 +1,28 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ define_recipe :geminstaller do
3
+ #
4
+ # Tasks
5
+ #
6
+ namespace :geminstaller do
7
+ desc "Run geminstaller"
8
+ task :run, :only => { :geminstaller => true } do
9
+ sudo "/usr/bin/geminstaller -c #{release_path}/config/geminstaller.yml --geminstaller-output=all --rubygems-output=all"
10
+ end
11
+
12
+ desc "Install geminstaller"
13
+ task :install, :only => { :geminstaller => true } do
14
+ sudo "gem install geminstaller"
15
+ sudo "gem source -a http://gems.github.com"
16
+ end
17
+ end
18
+
19
+ #
20
+ # Callbacks
21
+ #
22
+ after "deploy:setup", "geminstaller:install"
23
+ after "geminstaller:install", "geminstaller:run"
24
+ after "deploy:symlink", "geminstaller:run"
25
+ after "geminstaller:run", "deploy:migrate"
26
+ end
27
+
28
+ end
@@ -1,6 +1,6 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
- # Notify newrelic of the deploy
3
- if exists?(:use_newrelic)
2
+ define_recipe :newrelic do
3
+ # Tell Newrelic that we've deployed
4
4
  before "deploy:cleanup", "newrelic:notice_deployment"
5
5
  end
6
6
  end
@@ -0,0 +1,102 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ define_recipe :nginx do
4
+ #
5
+ # Configuration
6
+ #
7
+
8
+ # global vars
9
+ set :can_configure_nginx, true
10
+ set :nginx_user, 'nginx'
11
+ set :nginx_processes, 4
12
+ set :nginx_gzip_on, true
13
+ set :nginx_gzip_xml_on, false
14
+
15
+ # app specific vars
16
+ set :nginx_server_names, "_"
17
+ set :nginx_far_future, false
18
+ set :nginx_default_app, true
19
+
20
+ # http auth vars
21
+ set :nginx_auth_ip_masks, ['192.168.0.0/254']
22
+ set :nginx_http_auth_app, false
23
+ set :nginx_auth_locations, []
24
+ set :nginx_http_auth_users, []
25
+
26
+ #
27
+ # Tasks
28
+ #
29
+
30
+ namespace :nginx do
31
+
32
+ %w( start stop restart reload ).each do |cmd|
33
+ desc "#{cmd} your nginx servers"
34
+ task "#{cmd}".to_sym, :roles => :web do
35
+ default_run_options[:pty] = true
36
+ sudo "/etc/init.d/nginx #{cmd}"
37
+ end
38
+ end
39
+
40
+ desc "Setup Nginx vhost config"
41
+ task :vhost, :roles => :web do
42
+ result = render_erb_template(File.dirname(__FILE__) + "/templates/nginx.vhost.conf.erb")
43
+ put result, "/tmp/nginx.vhost.conf"
44
+ sudo "mkdir -p /etc/nginx/vhosts"
45
+ sudo "cp /tmp/nginx.vhost.conf /etc/nginx/vhosts/#{application}.conf"
46
+ inform "You must edit nginx.conf to include the vhost config file."
47
+ end
48
+
49
+ desc "Setup Nginx vhost auth config"
50
+ task :vhost_auth, :roles => :web do
51
+ result = render_erb_template(File.dirname(__FILE__) + "/templates/nginx.auth.conf.erb")
52
+ put result, "/tmp/nginx.auth.conf"
53
+ sudo "mkdir -p /etc/nginx/vhosts"
54
+ sudo "cp /tmp/nginx.vhost.conf /etc/nginx/vhosts/#{application}.auth.conf"
55
+ end
56
+
57
+ desc "Setup htpasswd file for nginx auth"
58
+ task :create_htpasswd, :roles => :web do
59
+ sudo "mkdir -p /etc/nginx/conf"
60
+ for user in nginx_http_auth_users
61
+ run "cd /etc/nginx/conf && htpasswd -b htpasswd #{user['name']} #{user['password']}"
62
+ # run <<-CMD
63
+ # cd /etc/nginx/conf;
64
+ # if [ ! -e /etc/nginx/conf/htpasswd ] ; then
65
+ # htpasswd -b -c htpasswd #{user['name']} #{user['password']};
66
+ # else
67
+ # htpasswd -b htpasswd #{user['name']} #{user['password']};
68
+ # fi
69
+ # CMD
70
+ end
71
+ end
72
+
73
+ desc "Setup Nginx.config"
74
+ task :conf, :roles => :web do
75
+ if can_configure_nginx
76
+
77
+ result = render_erb_template(File.dirname(__FILE__) + "/templates/nginx.conf.erb")
78
+ put result, "/tmp/nginx.conf"
79
+ sudo "cp /tmp/nginx.conf /etc/nginx/nginx.conf"
80
+
81
+ else
82
+ inform "Nginx configuration tasks have been disabled. Most likely you are deploying to engineyard which has it's own nginx conf setup."
83
+ end
84
+ end
85
+
86
+ desc "Setup Nginx vhost config and nginx.conf"
87
+ task :configure, :roles => :web do
88
+ if can_configure_nginx
89
+
90
+ conf
91
+ vhost
92
+ vhost_auth if nginx_auth_locations.length > 0 || nginx_http_auth_app
93
+ create_htpasswd if nginx_http_auth_users.length > 0
94
+
95
+ else
96
+ inform "Nginx configuration tasks have been disabled. Most likely you are deploying to engineyard which has it's own nginx conf setup."
97
+ end
98
+ end
99
+
100
+ end
101
+ end
102
+ end
File without changes
File without changes
@@ -0,0 +1,20 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ define_recipe :sass do
3
+ #
4
+ # Tasks
5
+ #
6
+ namespace :sass do
7
+ desc 'Updates the stylesheets generated by Sass'
8
+ task :update, :roles => :app do
9
+ invoke_command "cd #{latest_release}; RAILS_ENV=#{rails_env} rake sass:update"
10
+ end
11
+ end
12
+
13
+ #
14
+ # Callbacks
15
+ #
16
+
17
+ # Generate all the stylesheets manually (from their Sass templates) before each restart.
18
+ before 'deploy:restart', 'sass:update'
19
+ end
20
+ end
@@ -1,11 +1,6 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
2
 
3
3
  namespace :slice do
4
-
5
- desc "Copy the maintenance page from the public directory to the shared directory"
6
- task :copy_maintenance_page, :roles => :app do
7
- upload "public/maintenance.html","#{shared_path}/system/maintenance.html.custom", :via => :scp
8
- end
9
4
 
10
5
  desc "Tail the Rails import log for this environment"
11
6
  task :tail_import_logs, :roles => :utility do
@@ -28,7 +23,13 @@ Capistrano::Configuration.instance(:must_exist).load do
28
23
  end
29
24
 
30
25
  # Deploy the custom maintenance page
31
- if exists?(:use_custom_maintenance_page)
26
+ define_recipe :custom_maintenance_page do
27
+
28
+ desc "Copy the maintenance page from the public directory to the shared directory"
29
+ task :copy_maintenance_page, :roles => :app do
30
+ upload "public/maintenance.html","#{shared_path}/system/maintenance.html.custom", :via => :scp
31
+ end
32
+
32
33
  before "deploy:web:disable", "slice:copy_maintenance_page"
33
34
  end
34
35
 
File without changes
@@ -0,0 +1,48 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ define_recipe :symlinks do
4
+ #
5
+ # Callbacks
6
+ #
7
+ after "deploy:update_code", "symlinks:create"
8
+
9
+ #
10
+ # Configuration
11
+ #
12
+ set :symlink_dirs, []
13
+ set :symlink_absolute_dirs, []
14
+
15
+ #
16
+ # Tasks
17
+ #
18
+ namespace :symlinks do
19
+
20
+ desc "fix symlinks to shared directory"
21
+ task :fix, :roles => [:app, :web] do
22
+ # for folders stored under public
23
+ symlink_dirs.each do |share|
24
+ run "rm -rf #{current_path}/#{share}"
25
+ run "mkdir -p #{shared_path}/#{share}"
26
+ run "ln -nfs #{shared_path}/#{share} #{current_path}/#{share}"
27
+ end
28
+ end
29
+
30
+ desc "create symlinks to shared directory"
31
+ task :create, :roles => [:app, :web] do
32
+ # for folders stored under public
33
+ symlink_dirs.each do |share|
34
+ run "rm -rf #{release_path}/#{share}"
35
+ run "mkdir -p #{shared_path}/#{share}"
36
+ run "ln -nfs #{shared_path}/#{share} #{release_path}/#{share}"
37
+ end
38
+
39
+ symlink_absolute_dirs.each do |share|
40
+ run "rm -rf #{share[:symlink]}"
41
+ run "mkdir -p #{share[:source]}"
42
+ run "ln -nfs #{share[:source]} #{share[:symlink]}"
43
+ end
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,119 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ define_recipe :thin do
4
+
5
+ set :thin_servers, 2
6
+ set :thin_port, 8000
7
+ set :thin_address, "127.0.0.1"
8
+ set :thin_environment, "production"
9
+ set :thin_conf, nil
10
+ set :thin_user, nil
11
+ set :thin_group, nil
12
+ set :thin_prefix, nil
13
+ set :thin_pid_file, nil
14
+ set :thin_log_file, nil
15
+ set :thin_config_script, nil
16
+
17
+ namespace :thin do
18
+ desc <<-DESC
19
+ Install Thin script on the app server. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is
20
+ set to true.
21
+ DESC
22
+ task :install , :roles => :app do
23
+ send(run_method, "gem install thin")
24
+ send(run_method, "thin install")
25
+ end
26
+
27
+ desc <<-DESC
28
+ Configure thin processes on the app server. This uses the :use_sudo
29
+ variable to determine whether to use sudo or not. By default, :use_sudo is
30
+ set to true.
31
+ DESC
32
+ task :configure, :roles => :app do
33
+ set_conf
34
+
35
+ argv = []
36
+ argv << "thin"
37
+ argv << "-s #{thin_servers.to_s}"
38
+ argv << "-p #{thin_port.to_s}"
39
+ argv << "-e #{thin_environment}"
40
+ argv << "-a #{thin_address}"
41
+ argv << "-c #{current_path}"
42
+ argv << "-C #{thin_conf}"
43
+ argv << "-P #{thin_pid_file}" if thin_pid_file
44
+ argv << "-l #{thin_log_file}" if thin_log_file
45
+ argv << "--user #{thin_user}" if thin_user
46
+ argv << "--group #{thin_group}" if thin_group
47
+ argv << "--prefix #{thin_prefix}" if thin_prefix
48
+ argv << "config"
49
+ cmd = argv.join " "
50
+ send(run_method, cmd)
51
+ end
52
+
53
+ task :setup, :roles => :app do
54
+ thin.install
55
+ thin.configure
56
+ end
57
+
58
+ desc <<-DESC
59
+ Start Thin processes on the app server. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is
60
+ set to true.
61
+ DESC
62
+ task :start , :roles => :app do
63
+ set_conf
64
+ cmd = "thin start -C #{thin_conf}"
65
+ send(run_method, cmd)
66
+ end
67
+
68
+ desc <<-DESC
69
+ Restart the Thin processes on the app server by starting and stopping the cluster. This uses the :use_sudo
70
+ variable to determine whether to use sudo or not. By default, :use_sudo is set to true.
71
+ DESC
72
+ task :restart , :roles => :app do
73
+ set_conf
74
+ cmd = "thin restart -C #{thin_conf}"
75
+ send(run_method, cmd)
76
+ end
77
+
78
+ desc <<-DESC
79
+ Stop the Thin processes on the app server. This uses the :use_sudo
80
+ variable to determine whether to use sudo or not. By default, :use_sudo is
81
+ set to true.
82
+ DESC
83
+ task :stop , :roles => :app do
84
+ set_conf
85
+ cmd = "thin stop -C #{thin_conf}"
86
+ send(run_method, cmd)
87
+ end
88
+
89
+
90
+ def set_conf
91
+ set :thin_conf, "/etc/thin/#{application}.yml" unless thin_conf
92
+ end
93
+ end
94
+
95
+ namespace :deploy do
96
+ desc <<-DESC
97
+ Restart the Thin processes on the app server by calling thin:restart.
98
+ DESC
99
+ task :restart, :roles => :app do
100
+ thin.restart
101
+ end
102
+
103
+ desc <<-DESC
104
+ Start the Thin processes on the app server by calling thin:start.
105
+ DESC
106
+ task :start, :roles => :app do
107
+ thin.start
108
+ end
109
+
110
+ desc <<-DESC
111
+ Stop the Thin processes on the app server by calling thin:stop.
112
+ DESC
113
+ task :stop, :roles => :app do
114
+ thin.stop
115
+ end
116
+ end
117
+ end
118
+
119
+ end
@@ -1,6 +1,5 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
- # Make sphinx happy
3
- if exists?(:use_thinking_sphinx)
2
+ define_recipe :thinking_sphinx do
4
3
  after "deploy:update_code", "deploy:symlink_configs"
5
4
  after "deploy:symlink_configs", "thinking_sphinx:symlink"
6
5
  after "thinking_sphinx:symlink", "sphinx:configure"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factorylabs-fdlcap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Factory Design Labs
@@ -74,27 +74,30 @@ files:
74
74
  - features/step_definitions/fdlcap_steps.rb
75
75
  - features/support/env.rb
76
76
  - lib/fdlcap.rb
77
- - lib/fdlcap/autotagger.rb
78
- - lib/fdlcap/craken.rb
79
- - lib/fdlcap/database.rb
80
- - lib/fdlcap/delayed_job.rb
81
- - lib/fdlcap/deploy.rb
82
- - lib/fdlcap/geminstaller.rb
83
- - lib/fdlcap/newrelic.rb
84
- - lib/fdlcap/nginx.rb
85
- - lib/fdlcap/performance.rb
86
- - lib/fdlcap/rake.rb
77
+ - lib/fdlcap/defaults.rb
78
+ - lib/fdlcap/extensions/configuration.rb
79
+ - lib/fdlcap/extensions/recipe_definition.rb
87
80
  - lib/fdlcap/recipes.rb
88
- - lib/fdlcap/rsync.rb
89
- - lib/fdlcap/sass.rb
90
- - lib/fdlcap/slice.rb
91
- - lib/fdlcap/ssh.rb
92
- - lib/fdlcap/symlinks.rb
81
+ - lib/fdlcap/recipes/autotagger.rb
82
+ - lib/fdlcap/recipes/craken.rb
83
+ - lib/fdlcap/recipes/database.rb
84
+ - lib/fdlcap/recipes/delayed_job.rb
85
+ - lib/fdlcap/recipes/deploy.rb
86
+ - lib/fdlcap/recipes/geminstaller.rb
87
+ - lib/fdlcap/recipes/newrelic.rb
88
+ - lib/fdlcap/recipes/nginx.rb
89
+ - lib/fdlcap/recipes/performance.rb
90
+ - lib/fdlcap/recipes/rake.rb
91
+ - lib/fdlcap/recipes/rsync.rb
92
+ - lib/fdlcap/recipes/sass.rb
93
+ - lib/fdlcap/recipes/slice.rb
94
+ - lib/fdlcap/recipes/ssh.rb
95
+ - lib/fdlcap/recipes/symlinks.rb
96
+ - lib/fdlcap/recipes/thin.rb
97
+ - lib/fdlcap/recipes/thinking_sphinx.rb
93
98
  - lib/fdlcap/templates/nginx.auth.conf.erb
94
99
  - lib/fdlcap/templates/nginx.conf.erb
95
100
  - lib/fdlcap/templates/nginx.vhost.conf.erb
96
- - lib/fdlcap/thin.rb
97
- - lib/fdlcap/thinking_sphinx.rb
98
101
  - test/fdlcap_test.rb
99
102
  - test/test_helper.rb
100
103
  has_rdoc: false
data/lib/fdlcap/craken.rb DELETED
@@ -1,6 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do
2
- # Run craken to get cron tasks installed
3
- if exists?(:use_craken)
4
- after "deploy:update", "craken:install"
5
- end
6
- end
@@ -1,26 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do
2
- namespace :geminstaller do
3
- desc "Run geminstaller"
4
- task :run, :only => { :geminstaller => true } do
5
- sudo "/usr/bin/geminstaller -c #{release_path}/config/geminstaller.yml --geminstaller-output=all --rubygems-output=all"
6
- end
7
-
8
- desc "Install geminstaller"
9
- task :install, :only => { :geminstaller => true } do
10
- sudo "gem install geminstaller"
11
- sudo "gem source -a http://gems.github.com"
12
- end
13
- end
14
-
15
- #
16
- # Configure Callbacks
17
- #
18
- # Run geminstaller to make sure gems are installed.
19
- if exists?(:use_geminstaller)
20
- after "deploy:setup", "geminstaller:install"
21
- after "geminstaller:install", "geminstaller:run"
22
- after "deploy:symlink", "geminstaller:run"
23
- after "geminstaller:run", "deploy:migrate"
24
- end
25
-
26
- end
data/lib/fdlcap/nginx.rb DELETED
@@ -1,125 +0,0 @@
1
-
2
- #global vars
3
- set(:can_configure_nginx, true)
4
- set(:nginx_user, 'nginx')
5
- set(:nginx_processes, 4)
6
- set(:nginx_gzip_on, true)
7
- set(:nginx_gzip_xml_on, false)
8
-
9
- # app specific vars
10
- set(:nginx_server_names, "_")
11
- set(:nginx_far_future, false)
12
- set(:nginx_default_app, true)
13
-
14
- #http auth vars
15
- set(:nginx_auth_ip_masks, ['192.168.0.0/254'])
16
- set(:nginx_http_auth_app, false)
17
- set(:nginx_auth_locations, [])
18
- set(:nginx_http_auth_users, [])
19
-
20
- namespace :nginx do
21
-
22
- %w( start stop restart reload ).each do |cmd|
23
- desc "#{cmd} your nginx servers"
24
- task "#{cmd}".to_sym, :roles => :web do
25
- default_run_options[:pty] = true
26
- sudo "/etc/init.d/nginx #{cmd}"
27
- end
28
- end
29
-
30
- desc "Setup Nginx vhost config"
31
- task :vhost, :roles => :web do
32
- result = render_erb_template(File.dirname(__FILE__) + "/templates/nginx.vhost.conf.erb")
33
- put result, "/tmp/nginx.vhost.conf"
34
- sudo "mkdir -p /etc/nginx/vhosts"
35
- sudo "cp /tmp/nginx.vhost.conf /etc/nginx/vhosts/#{application}.conf"
36
- inform "You must edit nginx.conf to include the vhost config file."
37
- end
38
-
39
- desc "Setup Nginx vhost auth config"
40
- task :vhost_auth, :roles => :web do
41
- result = render_erb_template(File.dirname(__FILE__) + "/templates/nginx.auth.conf.erb")
42
- put result, "/tmp/nginx.auth.conf"
43
- sudo "mkdir -p /etc/nginx/vhosts"
44
- sudo "cp /tmp/nginx.vhost.conf /etc/nginx/vhosts/#{application}.auth.conf"
45
- end
46
-
47
- desc "Setup htpasswd file for nginx auth"
48
- task :create_htpasswd, :roles => :web do
49
- sudo "mkdir -p /etc/nginx/conf"
50
- for user in nginx_http_auth_users
51
- run "cd /etc/nginx/conf && htpasswd -b htpasswd #{user['name']} #{user['password']}"
52
- # run <<-CMD
53
- # cd /etc/nginx/conf;
54
- # if [ ! -e /etc/nginx/conf/htpasswd ] ; then
55
- # htpasswd -b -c htpasswd #{user['name']} #{user['password']};
56
- # else
57
- # htpasswd -b htpasswd #{user['name']} #{user['password']};
58
- # fi
59
- # CMD
60
- end
61
- end
62
-
63
- desc "Setup Nginx.config"
64
- task :conf, :roles => :web do
65
- if can_configure_nginx
66
-
67
- result = render_erb_template(File.dirname(__FILE__) + "/templates/nginx.conf.erb")
68
- put result, "/tmp/nginx.conf"
69
- sudo "cp /tmp/nginx.conf /etc/nginx/nginx.conf"
70
-
71
- else
72
- inform "Nginx configuration tasks have been disabled. Most likely you are deploying to engineyard which has it's own nginx conf setup."
73
- end
74
- end
75
-
76
- desc "Setup Nginx vhost config and nginx.conf"
77
- task :configure, :roles => :web do
78
- if can_configure_nginx
79
-
80
- conf
81
- vhost
82
- vhost_auth if nginx_auth_locations.length > 0 || nginx_http_auth_app
83
- create_htpasswd if nginx_http_auth_users.length > 0
84
-
85
- else
86
- inform "Nginx configuration tasks have been disabled. Most likely you are deploying to engineyard which has it's own nginx conf setup."
87
- end
88
- end
89
-
90
- end
91
-
92
- class Capistrano::Configuration
93
-
94
- ##
95
- # Print an informative message with asterisks.
96
-
97
- def inform(message)
98
- puts "#{'*' * (message.length + 4)}"
99
- puts "* #{message} *"
100
- puts "#{'*' * (message.length + 4)}"
101
- end
102
-
103
- ##
104
- # Read a file and evaluate it as an ERB template.
105
- # Path is relative to this file's directory.
106
-
107
- def render_erb_template(filename)
108
- template = File.read(filename)
109
- result = ERB.new(template).result(binding)
110
- end
111
-
112
- ##
113
- # Run a command and return the result as a string.
114
- #
115
- # TODO May not work properly on multiple servers.
116
-
117
- def run_and_return(cmd)
118
- output = []
119
- run cmd do |ch, st, data|
120
- output << data
121
- end
122
- return output.to_s
123
- end
124
-
125
- end
data/lib/fdlcap/sass.rb DELETED
@@ -1,13 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do
2
- namespace :sass do
3
- desc 'Updates the stylesheets generated by Sass'
4
- task :update, :roles => :app do
5
- invoke_command "cd #{latest_release}; RAILS_ENV=#{rails_env} rake sass:update"
6
- end
7
- end
8
-
9
- # Generate all the stylesheets manually (from their Sass templates) before each restart.
10
- if exists?(:use_sass)
11
- before 'deploy:restart', 'sass:update'
12
- end
13
- end
@@ -1,38 +0,0 @@
1
- after "deploy:update_code", "symlinks:create"
2
-
3
- set(:symlink_dirs, [])
4
- set(:symlink_absolute_dirs, [])
5
-
6
- namespace :symlinks do
7
-
8
- desc <<-DESC
9
- fix symlinks to shared directory
10
- DESC
11
- task :fix, :roles => [:app, :web] do
12
- # for folders stored under public
13
- symlink_dirs.each do |share|
14
- run "rm -rf #{current_path}/#{share}"
15
- run "mkdir -p #{shared_path}/#{share}"
16
- run "ln -nfs #{shared_path}/#{share} #{current_path}/#{share}"
17
- end
18
- end
19
-
20
- desc <<-DESC
21
- create symlinks to shared directory
22
- DESC
23
- task :create, :roles => [:app, :web] do
24
- # for folders stored under public
25
- symlink_dirs.each do |share|
26
- run "rm -rf #{release_path}/#{share}"
27
- run "mkdir -p #{shared_path}/#{share}"
28
- run "ln -nfs #{shared_path}/#{share} #{release_path}/#{share}"
29
- end
30
-
31
- symlink_absolute_dirs.each do |share|
32
- run "rm -rf #{share[:symlink]}"
33
- run "mkdir -p #{share[:source]}"
34
- run "ln -nfs #{share[:source]} #{share[:symlink]}"
35
- end
36
- end
37
-
38
- end
data/lib/fdlcap/thin.rb DELETED
@@ -1,112 +0,0 @@
1
- set :thin_servers, 2
2
- set :thin_port, 8000
3
- set :thin_address, "127.0.0.1"
4
- set :thin_environment, "production"
5
- set :thin_conf, nil
6
- set :thin_user, nil
7
- set :thin_group, nil
8
- set :thin_prefix, nil
9
- set :thin_pid_file, nil
10
- set :thin_log_file, nil
11
- set :thin_config_script, nil
12
-
13
- namespace :thin do
14
- desc <<-DESC
15
- Install Thin script on the app server. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is
16
- set to true.
17
- DESC
18
- task :install , :roles => :app do
19
- send(run_method, "gem install thin")
20
- send(run_method, "thin install")
21
- end
22
-
23
- desc <<-DESC
24
- Configure thin processes on the app server. This uses the :use_sudo
25
- variable to determine whether to use sudo or not. By default, :use_sudo is
26
- set to true.
27
- DESC
28
- task :configure, :roles => :app do
29
- set_conf
30
-
31
- argv = []
32
- argv << "thin"
33
- argv << "-s #{thin_servers.to_s}"
34
- argv << "-p #{thin_port.to_s}"
35
- argv << "-e #{thin_environment}"
36
- argv << "-a #{thin_address}"
37
- argv << "-c #{current_path}"
38
- argv << "-C #{thin_conf}"
39
- argv << "-P #{thin_pid_file}" if thin_pid_file
40
- argv << "-l #{thin_log_file}" if thin_log_file
41
- argv << "--user #{thin_user}" if thin_user
42
- argv << "--group #{thin_group}" if thin_group
43
- argv << "--prefix #{thin_prefix}" if thin_prefix
44
- argv << "config"
45
- cmd = argv.join " "
46
- send(run_method, cmd)
47
- end
48
-
49
- task :setup, :roles => :app do
50
- thin.install
51
- thin.configure
52
- end
53
-
54
- desc <<-DESC
55
- Start Thin processes on the app server. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is
56
- set to true.
57
- DESC
58
- task :start , :roles => :app do
59
- set_conf
60
- cmd = "thin start -C #{thin_conf}"
61
- send(run_method, cmd)
62
- end
63
-
64
- desc <<-DESC
65
- Restart the Thin processes on the app server by starting and stopping the cluster. This uses the :use_sudo
66
- variable to determine whether to use sudo or not. By default, :use_sudo is set to true.
67
- DESC
68
- task :restart , :roles => :app do
69
- set_conf
70
- cmd = "thin restart -C #{thin_conf}"
71
- send(run_method, cmd)
72
- end
73
-
74
- desc <<-DESC
75
- Stop the Thin processes on the app server. This uses the :use_sudo
76
- variable to determine whether to use sudo or not. By default, :use_sudo is
77
- set to true.
78
- DESC
79
- task :stop , :roles => :app do
80
- set_conf
81
- cmd = "thin stop -C #{thin_conf}"
82
- send(run_method, cmd)
83
- end
84
-
85
-
86
- def set_conf
87
- set :thin_conf, "/etc/thin/#{application}.yml" unless thin_conf
88
- end
89
- end
90
-
91
- namespace :deploy do
92
- desc <<-DESC
93
- Restart the Thin processes on the app server by calling thin:restart.
94
- DESC
95
- task :restart, :roles => :app do
96
- thin.restart
97
- end
98
-
99
- desc <<-DESC
100
- Start the Thin processes on the app server by calling thin:start.
101
- DESC
102
- task :start, :roles => :app do
103
- thin.start
104
- end
105
-
106
- desc <<-DESC
107
- Stop the Thin processes on the app server by calling thin:stop.
108
- DESC
109
- task :stop, :roles => :app do
110
- thin.stop
111
- end
112
- end