magic_recipes 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -54,9 +54,20 @@ set :rails_env, "production" #=> Rails environmen
54
54
  # => # set :git_enable_submodules, 1 #=> Git submodules
55
55
 
56
56
 
57
+ # PostgreSQL
58
+ # => set :postgresql_host, "localhost" #=> postgres host
59
+ # => set :postgresql_user, "#{ app_name }" #=> postgres user
60
+ # => set :postgresql_password, "password" #=> postgres user password, if not set prompt will follow
61
+ # => set :postgresql_database, "#{ app_name }_#{ rails_env }" #=> postgres db name
62
+ # => set :postgresql_pool, 5 #=> postgres pool
63
+
64
+
57
65
  # SqLite3 ... this is more for test & try pupose (save .sqlite and copy to current after deploy)
58
66
  # => set :sqlite_path, "#{ deploy_to }/shared/db/" #=> shared path for db
59
67
  # => set :sqlite_db, "#{ rails_env }" #=> sqlite name
68
+ # SqLite3-callbacks
69
+ # => before "deploy", "sqlite:save_db"
70
+ # => after "deploy", "sqlite:copy_db"
60
71
 
61
72
 
62
73
  # if you want to clean up old releases on each deploy uncomment this:
@@ -66,15 +77,14 @@ set :rails_env, "production" #=> Rails environmen
66
77
 
67
78
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
68
79
  # Usage:
69
- # magic_recipes :rvm, :nginx, :private_pub, :thin
80
+ # magic_recipes :nginx, :private_pub, :rvm, :thin
70
81
  # available:
71
- # :rvm, :rbenv, :nginx, :private_pub, :thin, :passenger, :unicorn, :assets, :gems, :sqlite, :db
82
+ # :assets, :db, :gems, :nginx, :passenger, :postgresql, :private_pub, :rbenv, :rvm, :sqlite, :thin, :unicorn
83
+ # works great:
84
+ # :assets, :db, :nginx, :postgresql, :private_pub, :rvm, :sqlite, :thin
72
85
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
73
86
 
74
- magic_recipes :rvm, :nginx, :private_pub, :thin
87
+ magic_recipes :assets, :nginx, :rvm, :thin
75
88
 
76
89
 
77
- # SqLite3-callbacks ... this is more for test & try pupose (save .sqlite and copy to current after deploy)
78
- # => before "deploy", "sqlite:save_db"
79
- # => after "deploy", "sqlite:copy_db"
80
90
 
@@ -1,5 +1,23 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
+ # = Assets - Deploy-Recipes
4
+ #
5
+ # changed asset deployment .. include chmod 777 for public folder (my server need this)
6
+ #
7
+ # [Tasks:]
8
+ # :symlink # => set up a symlink to the shared directory
9
+ #
10
+ # :precompile # => Run the asset precompilation rake task
11
+ #
12
+ # :chmod # => make the public folder public for all (777)
13
+ #
14
+ # :clean # => Run the asset clean rake task
15
+ #
16
+ # [Callbacks:]
17
+ # before 'deploy:finalize_update', 'deploy:assets:symlink'
18
+ #
19
+ # after 'deploy:update_code', 'deploy:assets:precompile'
20
+ #
3
21
  module Assets
4
22
  def self.load_into(configuration)
5
23
  configuration.load do
@@ -1,5 +1,21 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
+ # = Db - Deploy-Recipes
4
+ #
5
+ # Some recipes to work with databases, especialy when you have an server, where you can't delete or create db's.
6
+ #
7
+ # [Tasks:]
8
+ # :seed # => seed the database
9
+ #
10
+ # :migrate # => migrate the database
11
+ #
12
+ # :delete_tables # => delete all Tables of the Database!
13
+ #
14
+ # :save_reset # => DB-Reset for user without dbcreate permission (deletes all tables than migrates again)
15
+ #
16
+ # [Callbacks:]
17
+ # - - -
18
+ #
3
19
  module Db
4
20
  def self.load_into(configuration)
5
21
  configuration.load do
@@ -1,5 +1,9 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
+ # = Gems - Deploy-Recipes
4
+ #
5
+ # == Useless .. take the capistrano task
6
+ #
3
7
  module Gems
4
8
  def self.load_into(configuration)
5
9
  configuration.load do
@@ -1,6 +1,10 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
- module Rvm
3
+ # = Git - Deploy-Recipes
4
+ #
5
+ # == NEED FIX .. doesnt work now !!!
6
+ #
7
+ module Git
4
8
  def self.load_into(configuration)
5
9
  configuration.load do
6
10
 
@@ -1,18 +1,26 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
- # Nginx - Deploy-Recipes
3
+ # = Nginx - Deploy-Recipes
4
4
  #
5
- # Tasks:
6
- # :install # => Install latest stable release of nginx
7
- # :setup # => Setup nginx configuration for this application
8
- # :start # => start nginx-server
9
- # :stop # => stop nginx-server
10
- # :restart # => setup, stop, start nginx-server
5
+ # Deploy Recipes for nginx.
11
6
  #
12
- # Callbacks:
13
- # after "deploy:install", "nginx:install"
14
- # after "deploy:setup", "nginx:setup"
15
- # after "deploy", "nginx:restart"
7
+ # [Tasks:]
8
+ # :install # => Install latest stable release of nginx
9
+ #
10
+ # :setup # => Setup nginx configuration for this application
11
+ #
12
+ # :start # => start nginx-server
13
+ #
14
+ # :stop # => stop nginx-server
15
+ #
16
+ # :restart # => setup, stop, start nginx-server
17
+ #
18
+ # [Callbacks:]
19
+ # after "deploy:install", "nginx:install"
20
+ #
21
+ # after "deploy:setup", "nginx:setup"
22
+ #
23
+ # after "deploy", "nginx:restart"
16
24
  #
17
25
  module Nginx
18
26
  def self.load_into(configuration)
@@ -1,5 +1,15 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
+ # = RVM - Deploy-Recipes
4
+ #
5
+ # == unused for now
6
+ #
7
+ # [Tasks:]
8
+ #
9
+ #
10
+ # [Callbacks:]
11
+ #
12
+ #
3
13
  module Nodejs
4
14
  def self.load_into(configuration)
5
15
  configuration.load do
@@ -1,15 +1,17 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
+ # = Passenger - Deploy
4
+ #
5
+ # Simple recipe to restart passenger
6
+ #
7
+ # [Tasks:]
8
+ # task :restart # => Restart Phusion-Passenger
9
+ #
10
+ # [Callbacks:]
11
+ # after "deploy:restart", "passenger:restart"
12
+ #
3
13
  module Passenger
4
14
 
5
- # Passenger - Deploy
6
- #
7
- # Tasks:
8
- # task :restart # => Restart Phusion-Passenger
9
- #
10
- # Callbacks:
11
- # after "deploy:restart", "passenger:restart"
12
- #
13
15
  def self.load_into(configuration)
14
16
  configuration.load do
15
17
 
@@ -1,6 +1,32 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
- module Assets
3
+ # = Postgresql - Deploy-Recipes
4
+ #
5
+ # Some simple recipes for PostgreSQL
6
+ #
7
+ # [Tasks:]
8
+ # :install # => Install the latest stable release of PostgreSQL.
9
+ #
10
+ # :create_database # => Create a database for this application.
11
+ #
12
+ # :setup # => Generate the database.yml configuration file.
13
+ #
14
+ # :symlink # => Symlink the database.yml file into latest release
15
+ #
16
+ # :kill_postgres_connections # => kill pgsql users so database can be dropped
17
+ #
18
+ # :drop_public_shema # => drop public shema so db is empty and not dropped
19
+ #
20
+ # [Callbacks:]
21
+ # after "deploy:install", "postgresql:install"
22
+ #
23
+ # after "deploy:setup", "postgresql:create_database"
24
+ #
25
+ # after "deploy:setup", "postgresql:setup"
26
+ #
27
+ # after "deploy:finalize_update", "postgresql:symlink"
28
+ #
29
+ module Postgresql
4
30
  def self.load_into(configuration)
5
31
  configuration.load do
6
32
 
@@ -9,7 +35,8 @@ module MagicRecipes
9
35
  set_default(:postgresql_host, "localhost")
10
36
  set_default(:postgresql_user) { application }
11
37
  set_default(:postgresql_password) { Capistrano::CLI.password_prompt "PostgreSQL Password: " }
12
- set_default(:postgresql_database) { "#{application}_production" }
38
+ set_default(:postgresql_database) { "#{application}_#{rails_env}" }
39
+ set_default(:postgresql_pool, 5)
13
40
 
14
41
  namespace :postgresql do
15
42
  desc "Install the latest stable release of PostgreSQL."
@@ -22,7 +49,8 @@ module MagicRecipes
22
49
 
23
50
  desc "Create a database for this application."
24
51
  task :create_database, roles: :db, only: {primary: true} do
25
- run %Q{#{sudo} -u postgres psql -c "create user #{postgresql_user} with password '#{postgresql_password}';"}
52
+ # with --createdb for rake commands
53
+ run %Q{#{sudo} -u postgres psql -c "create user --createdb #{postgresql_user} with password '#{postgresql_password}';"}
26
54
  run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
27
55
  end
28
56
  after "deploy:setup", "postgresql:create_database"
@@ -30,15 +58,30 @@ module MagicRecipes
30
58
  desc "Generate the database.yml configuration file."
31
59
  task :setup, roles: :app do
32
60
  run "mkdir -p #{shared_path}/config"
33
- template "postgresql.yml.erb", "#{shared_path}/config/database.yml"
61
+ template "postgresql.yml.erb", "#{shared_path}/config/postgres_#{rails_env}.yml"
34
62
  end
35
63
  after "deploy:setup", "postgresql:setup"
36
64
 
37
65
  desc "Symlink the database.yml file into latest release"
38
66
  task :symlink, roles: :app do
39
- run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
67
+ run "ln -nfs #{shared_path}/config/postgres_#{rails_env}.yml #{release_path}/config/database.yml"
40
68
  end
41
69
  after "deploy:finalize_update", "postgresql:symlink"
70
+
71
+ # http://stackoverflow.com/a/12939218/1470996
72
+ desc 'kill pgsql users so database can be dropped'
73
+ task :kill_postgres_connections do
74
+ # run "echo 'SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname=\'#{postgresql_database}\';' | psql -U postgres"
75
+ run %Q{#{sudo} -u postgres psql -c "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname='#{postgresql_database}';"}
76
+ end
77
+
78
+
79
+
80
+ desc 'drop public shema so db is empty and not dropped'
81
+ task :drop_public_shema do
82
+ run %Q{#{sudo} -u postgres psql -c "drop schema public cascade on #{postgresql_database};';"}
83
+ end
84
+
42
85
  end
43
86
 
44
87
  # eof
@@ -1,5 +1,33 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
+ # = PrivatePub - Deploy-Recipes
4
+ #
5
+ # Easy deployment of private_pub .. which can be frustrating on nginx because of the tcp server
6
+ #
7
+ # [Tasks:]
8
+ # :reconf # => Generate the thin yml configuration file.
9
+ #
10
+ # :setup # => Generate the nginx configuration file.
11
+ #
12
+ # :yml_file # => Generate the private_pup yml configuration file.
13
+ #
14
+ # :start # => Start the private_pup server
15
+ #
16
+ # :stop # => Start the private_pup server
17
+ #
18
+ # :restart # => Restart the private_pup server
19
+ #
20
+ # [Callbacks:]
21
+ # before "thin:start", "private_pub:yml_file"
22
+ #
23
+ # after "thin:start", "private_pub:start"
24
+ #
25
+ # after "thin:stop", "private_pub:stop"
26
+ #
27
+ # after "nginx:setup", "private_pub:setup"
28
+ #
29
+ # after "thin:reconf", "private_pub:reconf"
30
+ #
3
31
  module PrivatePub
4
32
  def self.load_into(configuration)
5
33
  configuration.load do
@@ -1,5 +1,15 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
+ # = RVM - Deploy-Recipes
4
+ #
5
+ # == unused for now
6
+ #
7
+ # [Tasks:]
8
+ #
9
+ #
10
+ # [Callbacks:]
11
+ #
12
+ #
3
13
  module Rbenv
4
14
  def self.load_into(configuration)
5
15
  configuration.load do
@@ -1,5 +1,15 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
+ # = RVM - Deploy-Recipes
4
+ #
5
+ # little helper to work on crazy rvm mashine ... mine dont accept the standard rvm handling
6
+ #
7
+ # [Tasks:]
8
+ # - - -
9
+ #
10
+ # [Callbacks:]
11
+ # - - -
12
+ #
3
13
  module Rvm
4
14
  def self.load_into(configuration)
5
15
  configuration.load do
@@ -1,5 +1,21 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
+ # = RVM - Deploy-Recipes
4
+ #
5
+ # This is more for test & try pupose. Save .sqlite and copy to current after deploy.
6
+ #
7
+ # [Tasks:]
8
+ # :setup_db # => Create shared folder.
9
+ #
10
+ # :save_db # => Copy current DB to shared folder.
11
+ #
12
+ # :copy_db # => Copy saved DB from shared folder to current_release
13
+ #
14
+ # [Callbacks:]
15
+ # after "deploy:setup", "sqlite:setup_db"
16
+ #
17
+ # more in deploy.rb ! .. becasuse ist just in case you need it .. and only works after second deploy !
18
+ #
3
19
  module Sqlite
4
20
  def self.load_into(configuration)
5
21
  configuration.load do
@@ -1,8 +1,8 @@
1
- production:
1
+ <%= rails_env %>:
2
2
  adapter: postgresql
3
3
  encoding: unicode
4
4
  database: <%= postgresql_database %>
5
- pool: 5
5
+ pool: <%= postgresql_pool %>
6
6
  username: <%= postgresql_user %>
7
7
  password: <%= postgresql_password %>
8
8
  host: <%= postgresql_host %>
@@ -1,5 +1,23 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
+ # = Thin - Deploy-Recipes
4
+ #
5
+ # Simple recipe to work with thin, and app configurstion / registration.
6
+ #
7
+ # [Tasks:]
8
+ # :reconf # => Create or Update the thin yml configuration files
9
+ #
10
+ # :start # => Start the private_pup server
11
+ #
12
+ # :stop # => Start the private_pup server
13
+ #
14
+ # :restart # => Restart the private_pup server
15
+ #
16
+ # [Callbacks:]
17
+ # before "nginx:start", "thin:start"
18
+ #
19
+ # before "nginx:stop", "thin:stop"
20
+ #
3
21
  module Thin
4
22
  def self.load_into(configuration)
5
23
  configuration.load do
@@ -1,5 +1,15 @@
1
1
  # encoding: utf-8
2
2
  module MagicRecipes
3
+ # = RVM - Deploy-Recipes
4
+ #
5
+ # == unused for now
6
+ #
7
+ # [Tasks:]
8
+ #
9
+ #
10
+ # [Callbacks:]
11
+ #
12
+ #
3
13
  module Unicorn
4
14
  def self.load_into(configuration)
5
15
  configuration.load do
data/lib/magic_recipes.rb CHANGED
@@ -1,6 +1,45 @@
1
1
  require 'capistrano'
2
2
 
3
3
  module MagicRecipes
4
+ # = MagicRecipes
5
+ #
6
+ # Some capistrano-recipes for our deployment .. still in development!
7
+ #
8
+ # [Methods:]
9
+ # template(from, to) # => write erb template to path
10
+ #
11
+ # set_default(name, *args, &block) # => set default value
12
+ #
13
+ # random_string(length=42) # => generate a random string
14
+ #
15
+ # use_recipe(recipe_name) # => load one recipe
16
+ #
17
+ # magic_recipes(*recipes) # => load several recipes
18
+ #
19
+ # [Usage:]
20
+ # add magic_recipes to your Gemfile
21
+ # gem 'magic_recipes', :require => nil
22
+ #
23
+ # install the gem
24
+ # bundle install
25
+ #
26
+ # run the generator
27
+ # rails g magic_recipes:capify
28
+ #
29
+ # edit 'config/deploy'
30
+ #
31
+ # enjoy some magic!
32
+ #
33
+ # [config/deploy.rb:]
34
+ #
35
+ # uncomment and edit all needed vars
36
+ #
37
+ # add all recipes
38
+ # magic_recipes :assets, :db, :nginx, :postgresql, :private_pub, :rvm, :sqlite, :thin
39
+ #
40
+ # add your recipes
41
+ # magic_recipes :assets, :nginx, :rvm, :thin
42
+ #
4
43
  def self.load_into(configuration)
5
44
  configuration.load do
6
45
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magic_recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-27 00:00:00.000000000 Z
12
+ date: 2012-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails