magic_recipes 0.0.14 → 0.0.15
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.markdown +38 -10
- data/lib/generators/magic_recipes/git_cap_generator.rb +35 -0
- data/lib/generators/magic_recipes/templates/deploy.rb.tt +6 -1
- data/lib/generators/magic_recipes/templates/git_cap.tt +35 -0
- data/lib/magic_recipes/nginx.rb +14 -0
- data/lib/magic_recipes/passenger.rb +9 -1
- data/lib/magic_recipes/sqlite.rb +49 -0
- metadata +7 -4
data/README.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MagicRecipes
|
2
2
|
|
3
|
-
|
3
|
+
Some capistrano-recipes for our deployment .. still in development!
|
4
4
|
|
5
5
|
Code is inspired by:
|
6
6
|
|
@@ -10,28 +10,33 @@ Code is inspired by:
|
|
10
10
|
|
11
11
|
|
12
12
|
## Usage
|
13
|
-
add magic_recipes to your Gemfile
|
14
13
|
|
15
|
-
|
14
|
+
add magic_recipes to your Gemfile
|
15
|
+
```ruby
|
16
|
+
gem 'magic_recipes', :require => nil
|
17
|
+
```
|
16
18
|
|
17
|
-
|
19
|
+
install the gem
|
20
|
+
```ruby
|
21
|
+
$ bundle install
|
22
|
+
```
|
18
23
|
|
19
24
|
run the generator
|
20
|
-
|
21
|
-
|
25
|
+
```ruby
|
26
|
+
$ rails g magic_recipes:capify
|
27
|
+
```
|
22
28
|
|
23
29
|
edit 'config/deploy'
|
24
30
|
|
25
|
-
enjoy some magic
|
31
|
+
enjoy some magic!
|
26
32
|
|
27
33
|
|
28
34
|
## ToDo´s
|
29
35
|
|
30
36
|
- add tests (rspec+cucumber)
|
31
37
|
- make expect-cap-task (bin/*_cap)
|
32
|
-
|
33
|
-
-
|
34
|
-
- add: puma, varnish, search-stuff, vps-stuff
|
38
|
+
- **improve:** passenger, unicorn rbenv, postgesql, nodejs, gems, db, git, rvm
|
39
|
+
- **add:** puma, varnish, search-stuff, vps-stuff
|
35
40
|
|
36
41
|
|
37
42
|
## Ready
|
@@ -42,6 +47,29 @@ and in use .. but not tested
|
|
42
47
|
- thin
|
43
48
|
- assets
|
44
49
|
- private_pub ... needs [nginx_tcp_proxy_module](https://github.com/yaoweibin/nginx_tcp_proxy_module) for nginx
|
50
|
+
- *sqlite* ... this is more for test & try pupose (save .sqlite and copy to current after deploy)
|
51
|
+
|
52
|
+
|
53
|
+
## More .. ( special feature )
|
54
|
+
|
55
|
+
There's also an Except-Script (bin/git_cap) which is great if you use a private-git-repository ... so you don't need to provide your git-username and git-password twice every deploy.
|
56
|
+
|
57
|
+
**Usage**
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
$ rails g magic_recipes:git_cap # => from app folder .. copy git_cap file
|
61
|
+
$ git_cap git_name git_password # => from app folder .. start silent depoy
|
62
|
+
```
|
63
|
+
|
64
|
+
or add an alias in ~/.profile | ~/.bash_rc
|
65
|
+
```ruby
|
66
|
+
alias git_deploy='./git_cap git_name git_password'
|
67
|
+
```
|
68
|
+
|
69
|
+
and start with
|
70
|
+
```ruby
|
71
|
+
$ git_deploy
|
72
|
+
```
|
45
73
|
|
46
74
|
### Licence
|
47
75
|
This project rocks and uses MIT-LICENSE.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rails/generators'
|
3
|
+
|
4
|
+
module MagicRecipes
|
5
|
+
module Generators
|
6
|
+
class GitCapGenerator < Rails::Generators::Base
|
7
|
+
source_root File.expand_path("../templates", __FILE__)
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
# => argument :git_name, :type => :string, :banner => 'GitName', :default => "git_name"
|
11
|
+
# => argument :git_password, :type => :string, :banner => 'GitPassword', :default => "git_password"
|
12
|
+
# => def initialize(args, *options) #:nodoc:
|
13
|
+
# => super
|
14
|
+
# => end
|
15
|
+
|
16
|
+
desc "Some visuals."
|
17
|
+
def initial_desc
|
18
|
+
puts(' * * * * * * * * * * * * * * * * * * * * * * * * * *')
|
19
|
+
puts(' - - - - - - M A G I C - R E C I P E S : git-deploy-helper - - - - - - - -')
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "copy git_cap file."
|
23
|
+
def create_git_cap_files
|
24
|
+
template "git_cap.tt", "#{ Rails.root }/git_cap"
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "More visuals."
|
28
|
+
def end_desc
|
29
|
+
puts(" - - - - - - Usage: $ git_cap [git_name] [git_password] - - - - - - - -")
|
30
|
+
puts(' * * * * * * * * * * * * * * * * * * * * * * * * * *')
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -54,6 +54,11 @@ set :rails_env, "production" #=> Rails environmen
|
|
54
54
|
# => # set :git_enable_submodules, 1 #=> Git submodules
|
55
55
|
|
56
56
|
|
57
|
+
# SqLite3 ... this is more for test & try pupose (save .sqlite and copy to current after deploy)
|
58
|
+
set :sqlite_path, "#{ deploy_to }/shared/db/" #=> shared path for db
|
59
|
+
set :sqlite_db, "#{ rails_env.downcase.strip }" #=> sqlite name
|
60
|
+
|
61
|
+
|
57
62
|
# if you want to clean up old releases on each deploy uncomment this:
|
58
63
|
# => set :keep_releases, 3
|
59
64
|
# => after "deploy:restart", "deploy:cleanup"
|
@@ -63,7 +68,7 @@ set :rails_env, "production" #=> Rails environmen
|
|
63
68
|
# Usage:
|
64
69
|
# magic_recipes :rvm, :nginx, :private_pub, :thin
|
65
70
|
# available:
|
66
|
-
# :rvm, :rbenv, :nginx, :private_pub, :thin, :passenger, :unicorn, :assets, :gems
|
71
|
+
# :rvm, :rbenv, :nginx, :private_pub, :thin, :passenger, :unicorn, :assets, :gems, :sqlite, :db
|
67
72
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
68
73
|
|
69
74
|
magic_recipes :rvm, :nginx, :private_pub, :thin
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/expect -f
|
2
|
+
# Expect script to supply username/password to cap deploy to git private repository
|
3
|
+
# This script needs username and password as arguments to connect to git server:
|
4
|
+
# ------------------------------------------------------------------------
|
5
|
+
# ./git_cap gitusr gitpwd
|
6
|
+
# -------------------------------------------------------------------------
|
7
|
+
# set Variables
|
8
|
+
set g_user [lrange $argv 0 0]
|
9
|
+
set g_pwd [lrange $argv 1 1]
|
10
|
+
set timeout -1
|
11
|
+
|
12
|
+
spawn cap deploy
|
13
|
+
match_max 100000
|
14
|
+
|
15
|
+
# Look for user prompt
|
16
|
+
expect "*?sername:*"
|
17
|
+
send -- "$g_user\r"
|
18
|
+
send -- "\r"
|
19
|
+
|
20
|
+
# Look for passwod prompt
|
21
|
+
expect "*?assword:*"
|
22
|
+
send -- "$g_pwd\r"
|
23
|
+
send -- "\r"
|
24
|
+
|
25
|
+
# Look for user prompt
|
26
|
+
expect "*?sername:*"
|
27
|
+
send -- "$g_user\r"
|
28
|
+
send -- "\r"
|
29
|
+
|
30
|
+
# Look for passwod prompt
|
31
|
+
expect "*?assword:*"
|
32
|
+
send -- "$g_pwd\r"
|
33
|
+
send -- "\r"
|
34
|
+
|
35
|
+
expect eof
|
data/lib/magic_recipes/nginx.rb
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module MagicRecipes
|
3
|
+
# Nginx - Deploy-Recipes
|
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
|
11
|
+
#
|
12
|
+
# Callbacks:
|
13
|
+
# after "deploy:install", "nginx:install"
|
14
|
+
# after "deploy:setup", "nginx:setup"
|
15
|
+
# after "deploy", "nginx:restart"
|
16
|
+
#
|
3
17
|
module Nginx
|
4
18
|
def self.load_into(configuration)
|
5
19
|
configuration.load do
|
@@ -1,6 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module MagicRecipes
|
3
3
|
module Passenger
|
4
|
+
|
5
|
+
# Passenger - Deploy
|
6
|
+
#
|
7
|
+
# Tasks:
|
8
|
+
# task :restart # => Restart Phusion-Passenger
|
9
|
+
#
|
10
|
+
# Callbacks:
|
11
|
+
# after "deploy:restart", "passenger:restart"
|
12
|
+
#
|
4
13
|
def self.load_into(configuration)
|
5
14
|
configuration.load do
|
6
15
|
|
@@ -8,7 +17,6 @@ module MagicRecipes
|
|
8
17
|
|
9
18
|
namespace :passenger do
|
10
19
|
|
11
|
-
# Restart Passenger
|
12
20
|
desc "Restart - Passenger"
|
13
21
|
task :restart, :roles => :app, :except => { :no_release => true } do
|
14
22
|
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module MagicRecipes
|
3
|
+
module Sqlite
|
4
|
+
def self.load_into(configuration)
|
5
|
+
configuration.load do
|
6
|
+
|
7
|
+
set_default :sqlite_path, "#{ deploy_to }/shared/db/"
|
8
|
+
set_default :sqlite_db, "#{ rails_env.downcase.strip }"
|
9
|
+
|
10
|
+
namespace :sqlite do
|
11
|
+
|
12
|
+
desc "save current db"
|
13
|
+
task :save_db do
|
14
|
+
if use_rvm
|
15
|
+
run <<-CMD
|
16
|
+
#{rvm_cmd} &&
|
17
|
+
cd #{deploy_to}/current/db &&
|
18
|
+
cp -f #{ sqlite_db }.sqlite3 #{ sqlite_path }/
|
19
|
+
CMD
|
20
|
+
else
|
21
|
+
run "cd #{deploy_to}/current/db && cp #{ sqlite_db }.sqlite3 #{sqlite_path}/"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "copy the database"
|
26
|
+
task :copy_db do
|
27
|
+
if use_rvm
|
28
|
+
run <<-CMD
|
29
|
+
#{rvm_cmd} &&
|
30
|
+
cd #{sqlite_path} &&
|
31
|
+
cp -f #{ sqlite_db }.sqlite3 #{deploy_to}/current/db/
|
32
|
+
CMD
|
33
|
+
else
|
34
|
+
run "cd #{sqlite_path} && cp -f #{ sqlite_db }.sqlite3 #{deploy_to}/current/db/"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
before "deploy", "sqlite:save_db"
|
41
|
+
after "deploy", "sqlite:copy_db"
|
42
|
+
|
43
|
+
# eof
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
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.
|
4
|
+
version: 0.0.15
|
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-
|
12
|
+
date: 2012-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -171,8 +171,8 @@ dependencies:
|
|
171
171
|
- - ! '>='
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
|
-
description:
|
175
|
-
|
174
|
+
description: Our capistrano recipes for nginx, passenger, thin, private_pub, .. include
|
175
|
+
expect-script for silent-deployment of private git-repos.
|
176
176
|
email:
|
177
177
|
- torstenwetzel@berlinmagic.com
|
178
178
|
executables: []
|
@@ -182,8 +182,10 @@ files:
|
|
182
182
|
- bin/g_cap
|
183
183
|
- bin/git_cap
|
184
184
|
- lib/generators/magic_recipes/capify_generator.rb
|
185
|
+
- lib/generators/magic_recipes/git_cap_generator.rb
|
185
186
|
- lib/generators/magic_recipes/templates/Capfile.tt
|
186
187
|
- lib/generators/magic_recipes/templates/deploy.rb.tt
|
188
|
+
- lib/generators/magic_recipes/templates/git_cap.tt
|
187
189
|
- lib/magic_recipes/assets.rb
|
188
190
|
- lib/magic_recipes/db.rb
|
189
191
|
- lib/magic_recipes/gems.rb
|
@@ -195,6 +197,7 @@ files:
|
|
195
197
|
- lib/magic_recipes/private_pub.rb
|
196
198
|
- lib/magic_recipes/rbenv.rb
|
197
199
|
- lib/magic_recipes/rvm.rb
|
200
|
+
- lib/magic_recipes/sqlite.rb
|
198
201
|
- lib/magic_recipes/templates/nginx_passenger.erb
|
199
202
|
- lib/magic_recipes/templates/nginx_private_pub.erb
|
200
203
|
- lib/magic_recipes/templates/nginx_thin.erb
|