soprano 0.3
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/.gitignore +26 -0
- data/Gemfile +4 -0
- data/LICENSE +19 -0
- data/README.md +47 -0
- data/Rakefile +2 -0
- data/lib/soprano/version.rb +3 -0
- data/lib/soprano.rb +9 -0
- data/recipes/daemon_strategies/mongrel_cluster.rb +6 -0
- data/recipes/daemon_strategies/passenger.rb +17 -0
- data/recipes/daemon_strategy.rb +7 -0
- data/recipes/db.rb +97 -0
- data/recipes/defaults.rb +33 -0
- data/recipes/delayed_job.rb +7 -0
- data/recipes/nginx.rb +34 -0
- data/recipes/replicate.rb +3 -0
- data/soprano.gemspec +22 -0
- metadata +98 -0
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
pkg
|
20
|
+
*.gem
|
21
|
+
.bundle
|
22
|
+
Gemfile.lock
|
23
|
+
pkg/*
|
24
|
+
|
25
|
+
## PROJECT::SPECIFIC
|
26
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2011 by Dmitriy Kiriyenko
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Soprano
|
2
|
+
|
3
|
+
[](http://www.imdb.com/title/tt0141842/)
|
4
|
+
|
5
|
+
Soprano is the set of Capistrano recipes that help me to deploy my
|
6
|
+
applications.
|
7
|
+
|
8
|
+
Soprano by default uses Mongrel cluster (or Passenger) as an application
|
9
|
+
server, nginx as a web server, MySQL as a database server and git as a SCM.
|
10
|
+
|
11
|
+
The latest version of Soprano was inspired by Rubaidh's
|
12
|
+
[Rubaidhstrano](http://github.com/rubaidh/rubaidhstrano) and some code has
|
13
|
+
been borrowed from its sources.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
For Rails 3 add to your `Gemfile`:
|
18
|
+
|
19
|
+
gem 'soprano', :require => false
|
20
|
+
|
21
|
+
## Example usage
|
22
|
+
|
23
|
+
To start using Soprano you just need to add `require "soprano"` to your
|
24
|
+
`config/deploy.rb` file and set some variables:
|
25
|
+
|
26
|
+
require "soprano"
|
27
|
+
|
28
|
+
set :application, "set your application name here"
|
29
|
+
set :repository, "set your repository location here"
|
30
|
+
set :host, "set your host here"
|
31
|
+
|
32
|
+
# See soprano/recipes/defaults.rb for defaults
|
33
|
+
|
34
|
+
## Features
|
35
|
+
|
36
|
+
Readme about features in process...
|
37
|
+
|
38
|
+
## Thanks
|
39
|
+
|
40
|
+
- Jamis Buck for [Capistrano](https://github.com/halorgium/capistrano),
|
41
|
+
- Rubaidh Ltd for their awesome
|
42
|
+
[Rubaidhstrano](http://github.com/rubaidh/rubaidhstrano),
|
43
|
+
- Denis Barushev for [Capone](https://github.com/denis/capone).
|
44
|
+
|
45
|
+
## Copyright
|
46
|
+
|
47
|
+
Copyright (c) 2011 Dmitriy Kiriyenko. See LICENSE for details.
|
data/Rakefile
ADDED
data/lib/soprano.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
namespace :deploy do
|
2
|
+
desc "Start application."
|
3
|
+
task :start, :roles => :app do
|
4
|
+
run "touch #{current_release}/tmp/restart.txt"
|
5
|
+
end
|
6
|
+
|
7
|
+
desc "Stop application."
|
8
|
+
task :stop, :roles => :app do
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Restart application."
|
12
|
+
task :restart, :roles => :app do
|
13
|
+
run "touch #{current_release}/tmp/restart.txt"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
depend :remote, :gem, "passenger", ">=2.2.2"
|
data/recipes/db.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
namespace :soprano do
|
2
|
+
namespace :db do
|
3
|
+
desc <<-DESC
|
4
|
+
Create MySQL user and database using data from config/database.yml.
|
5
|
+
DESC
|
6
|
+
task :setup, :roles => :db, :only => { :primary => true } do
|
7
|
+
config = YAML::load(File.open("config/database.yml"))[rails_env]
|
8
|
+
root_password = Capistrano::CLI.password_prompt(prompt="Enter a root password for MySQL: ")
|
9
|
+
|
10
|
+
run "mysql --user='root' --password='#{root_password}' -e \"CREATE DATABASE IF NOT EXISTS #{config["database"]} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL PRIVILEGES ON #{config["database"]}.* TO '#{config["username"]}'@'localhost' IDENTIFIED BY '#{config["password"]}' WITH GRANT OPTION;\""
|
11
|
+
end
|
12
|
+
|
13
|
+
desc <<-DESC
|
14
|
+
Load fixtures from db/fixtures to the database.
|
15
|
+
DESC
|
16
|
+
task :load_fixtures, :roles => :db, :only => { :primary => true } do
|
17
|
+
run "rake db:fixtures:load FIXTURES_PATH=db/fixtures RAILS_ENV=#{rails_env} -f #{release_path}/Rakefile"
|
18
|
+
end
|
19
|
+
|
20
|
+
desc <<-DESC
|
21
|
+
Dumps the database for the current environment into db/env-data.sql.bz2.
|
22
|
+
Any existing backup will be overwritten.
|
23
|
+
DESC
|
24
|
+
task :backup, :roles => :db, :only => { :primary => true } do
|
25
|
+
config = YAML::load(File.open("config/database.yml"))[rails_env]
|
26
|
+
case config["adapter"]
|
27
|
+
when "mysql", "mysql2"
|
28
|
+
cmd = ["mysqldump"]
|
29
|
+
cmd << "--host='#{config['host']}'" unless config["host"].nil?
|
30
|
+
cmd << "--user='#{config['username'].nil? ? 'root' : config['username']}'"
|
31
|
+
cmd << "--password='#{config['password']}'" unless config["password"].nil?
|
32
|
+
cmd << config["database"]
|
33
|
+
cmd << "| bzip2 > #{current_path}/db/#{rails_env}-data.sql.bz2"
|
34
|
+
run cmd.join(" ")
|
35
|
+
else
|
36
|
+
puts "Task not supported by '#{config['adapter']}'."
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc <<-DESC
|
41
|
+
Dump the database for the current environment and take a local copy.
|
42
|
+
DESC
|
43
|
+
task :download_backup, :roles => :db, :only => { :primary => true } do
|
44
|
+
backup
|
45
|
+
get "#{current_path}/db/#{rails_env}-data.sql.bz2", "db/#{rails_env}-data.sql.bz2"
|
46
|
+
end
|
47
|
+
|
48
|
+
desc <<-DESC
|
49
|
+
Load an existing database dump into the development environment's database.
|
50
|
+
DESC
|
51
|
+
task :load_backup do
|
52
|
+
run_locally "rake db:drop"
|
53
|
+
run_locally "rake db:create"
|
54
|
+
|
55
|
+
config = YAML::load(File.open("config/database.yml"))["development"]
|
56
|
+
case config["adapter"]
|
57
|
+
when "mysql", "mysql2"
|
58
|
+
cmd = ["bzcat db/#{rails_env}-data.sql.bz2 | mysql"]
|
59
|
+
cmd << "--host='#{config['host']}'" unless config["host"].nil?
|
60
|
+
cmd << "--user='#{config['username'].nil? ? 'root' : config['username']}'"
|
61
|
+
cmd << "--password='#{config['password']}'" unless config["password"].nil?
|
62
|
+
cmd << config["database"]
|
63
|
+
run_locally cmd.join(" ")
|
64
|
+
else
|
65
|
+
puts "Task not supported by '#{config['adapter']}'."
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
task :replicate do
|
70
|
+
download_backup
|
71
|
+
load_backup
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
on :load do
|
77
|
+
if fetch(:setup_database_after_deploy_setup, true)
|
78
|
+
after "deploy:setup", "soprano:db:setup"
|
79
|
+
end
|
80
|
+
|
81
|
+
if fetch(:load_fixtures_to_database_after_deploy_cold, false)
|
82
|
+
after "deploy:cold", "soprano:db:load_fixtures"
|
83
|
+
end
|
84
|
+
|
85
|
+
if fetch(:backup_database_before_migrations, false)
|
86
|
+
before "deploy:migrate", "soprano:db:backup"
|
87
|
+
end
|
88
|
+
|
89
|
+
if fetch(:disable_web_during_migrations, false)
|
90
|
+
before "deploy:migrations", "deploy:web:disable"
|
91
|
+
after "deploy:migrations", "deploy:web:enable"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
depend :remote, :command, "mysql"
|
96
|
+
depend :remote, :command, "mysqldump"
|
97
|
+
depend :remote, :command, "bzip2"
|
data/recipes/defaults.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
set :scm, :git
|
2
|
+
set :deploy_via, :remote_cache
|
3
|
+
|
4
|
+
set :rails_env, "production"
|
5
|
+
|
6
|
+
set(:deploy_to) { "/var/www/apps/#{application}" }
|
7
|
+
|
8
|
+
role(:app) { host }
|
9
|
+
role(:web) { host }
|
10
|
+
role(:db, :primary => true) { host }
|
11
|
+
|
12
|
+
set :use_sudo, false
|
13
|
+
|
14
|
+
# Needed for proper password prompts
|
15
|
+
default_run_options[:pty] = true
|
16
|
+
|
17
|
+
# SSH options
|
18
|
+
ssh_options[:forward_agent] = true
|
19
|
+
|
20
|
+
# You can redefine these variables in your config/deploy.rb
|
21
|
+
|
22
|
+
# set :daemon_strategy, :mongrel_cluster
|
23
|
+
# set :web_server, :nginx
|
24
|
+
|
25
|
+
# set :install_gems, true
|
26
|
+
|
27
|
+
# set :backup_database_before_migrations, false
|
28
|
+
# set :disable_web_during_migrations, false
|
29
|
+
# set :setup_database_after_deploy_setup, true
|
30
|
+
# set :load_fixtures_to_database_after_deploy_cold, false
|
31
|
+
|
32
|
+
# set :whenever, false
|
33
|
+
# set :delayed_job, false
|
data/recipes/nginx.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
namespace :soprano do
|
2
|
+
namespace :nginx do
|
3
|
+
desc <<-DESC
|
4
|
+
Enable virtual host.
|
5
|
+
DESC
|
6
|
+
task :enable_vhost, :roles => :web do
|
7
|
+
sudo "ln -fs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
|
8
|
+
sudo "/etc/init.d/nginx reload"
|
9
|
+
end
|
10
|
+
|
11
|
+
desc <<-DESC
|
12
|
+
Disable virtual host.
|
13
|
+
DESC
|
14
|
+
task :disable_vhost, :roles => :web do
|
15
|
+
sudo "rm /etc/nginx/sites-enabled/#{application}"
|
16
|
+
sudo "/etc/init.d/nginx reload"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc <<-DESC
|
20
|
+
Reload nginx configuration if the application nginx virtual host config file was changed.
|
21
|
+
DESC
|
22
|
+
task :reload_if_config_file_changed, :roles => :web do
|
23
|
+
run "bash -c \"if ! cmp #{previous_release}/config/nginx.conf #{current_path}/config/nginx.conf; then #{sudo} /etc/init.d/nginx reload; fi\""
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
on :load do
|
29
|
+
if fetch(:web_server, :nginx) == :nginx
|
30
|
+
before "deploy:start", "soprano:nginx:enable_vhost"
|
31
|
+
after "deploy:stop", "soprano:nginx:disable_vhost"
|
32
|
+
after "deploy:restart", "soprano:nginx:reload_if_config_file_changed"
|
33
|
+
end
|
34
|
+
end
|
data/soprano.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "soprano/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "soprano"
|
7
|
+
s.version = Capone::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Dmitriy Kiriyenko"]
|
10
|
+
s.email = ["dmitriy.kiriyenko@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/dmitriy-kiriyenko/soprano"
|
12
|
+
s.summary = %q{Soprano is the set of rake tasks and capistrano recipes.}
|
13
|
+
s.description = %q{Soprano is the set of rake tasks and capistrano recipes.
|
14
|
+
Use it to avoid writing typical scenarios and maintaining them
|
15
|
+
in favour of configuring your builds and deploys declaratively.}
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.add_dependency "capistrano", ">= 2.5.0"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soprano
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 13
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
version: "0.3"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Dmitriy Kiriyenko
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-11-04 00:00:00 Z
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: capistrano
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 27
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 5
|
31
|
+
- 0
|
32
|
+
version: 2.5.0
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: |-
|
36
|
+
Soprano is the set of rake tasks and capistrano recipes.
|
37
|
+
Use it to avoid writing typical scenarios and maintaining them
|
38
|
+
in favour of configuring your builds and deploys declaratively.
|
39
|
+
email:
|
40
|
+
- dmitriy.kiriyenko@gmail.com
|
41
|
+
executables: []
|
42
|
+
|
43
|
+
extensions: []
|
44
|
+
|
45
|
+
extra_rdoc_files: []
|
46
|
+
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/soprano.rb
|
54
|
+
- lib/soprano/version.rb
|
55
|
+
- recipes/daemon_strategies/mongrel_cluster.rb
|
56
|
+
- recipes/daemon_strategies/passenger.rb
|
57
|
+
- recipes/daemon_strategy.rb
|
58
|
+
- recipes/db.rb
|
59
|
+
- recipes/defaults.rb
|
60
|
+
- recipes/delayed_job.rb
|
61
|
+
- recipes/nginx.rb
|
62
|
+
- recipes/replicate.rb
|
63
|
+
- soprano.gemspec
|
64
|
+
homepage: https://github.com/dmitriy-kiriyenko/soprano
|
65
|
+
licenses: []
|
66
|
+
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
requirements: []
|
91
|
+
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 1.8.7
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: Soprano is the set of rake tasks and capistrano recipes.
|
97
|
+
test_files: []
|
98
|
+
|