sunrise-deploy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +42 -0
- data/Rakefile +25 -0
- data/lib/generators/sunrise/deploy/USAGE +8 -0
- data/lib/generators/sunrise/deploy/install_generator.rb +18 -0
- data/lib/generators/sunrise/deploy/templates/Capfile +2 -0
- data/lib/generators/sunrise/deploy/templates/deploy.rb +31 -0
- data/lib/sunrise-deploy.rb +3 -0
- data/lib/sunrise/deploy.rb +7 -0
- data/lib/sunrise/deploy/recipes.rb +3 -0
- data/lib/sunrise/deploy/recipes/appication.rb +64 -0
- data/lib/sunrise/deploy/recipes/assets.rb +35 -0
- data/lib/sunrise/deploy/recipes/bundle.rb +10 -0
- data/lib/sunrise/deploy/recipes/db.rb +28 -0
- data/lib/sunrise/deploy/recipes/sphinx.rb +30 -0
- data/lib/sunrise/deploy/strategy/simple.rb +20 -0
- data/lib/sunrise/deploy/version.rb +5 -0
- metadata +95 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 Fodojo http://fodojo.com/
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
= Sunrise Desploy
|
2
|
+
|
3
|
+
Simple deployment schema for project
|
4
|
+
|
5
|
+
== Install
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem "sunrise-deploy"
|
9
|
+
end
|
10
|
+
|
11
|
+
bundle install
|
12
|
+
|
13
|
+
rails generate sunrise:deploy:install
|
14
|
+
|
15
|
+
== Usage
|
16
|
+
|
17
|
+
Update code, bundle install, migrate, assets precompile and restart server:
|
18
|
+
|
19
|
+
bundle exec cap app:deploy
|
20
|
+
|
21
|
+
Update code:
|
22
|
+
|
23
|
+
bundle exec cap app:update
|
24
|
+
|
25
|
+
Restart server:
|
26
|
+
|
27
|
+
bundle exec cap app:restart
|
28
|
+
|
29
|
+
Migrate db:
|
30
|
+
|
31
|
+
bundle exec cap app:migrate
|
32
|
+
|
33
|
+
Precompile assets:
|
34
|
+
|
35
|
+
bundle exec cap assets:precompile
|
36
|
+
|
37
|
+
Bundler install:
|
38
|
+
|
39
|
+
bundle exec cap bundle:install
|
40
|
+
|
41
|
+
|
42
|
+
Copyright (c) 2012 Fodojo, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require File.join(File.dirname(__FILE__), 'lib', 'sunrise', 'deploy', 'version')
|
6
|
+
|
7
|
+
desc 'Default: run unit tests.'
|
8
|
+
task :default => :test
|
9
|
+
|
10
|
+
desc 'Test the sunrise plugin.'
|
11
|
+
Rake::TestTask.new(:test) do |t|
|
12
|
+
t.libs << 'lib'
|
13
|
+
t.libs << 'test'
|
14
|
+
t.pattern = 'test/**/*_test.rb'
|
15
|
+
t.verbose = true
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Generate documentation for the sunrise plugin.'
|
19
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
20
|
+
rdoc.rdoc_dir = 'rdoc'
|
21
|
+
rdoc.title = 'Sunrise Deploy'
|
22
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
23
|
+
rdoc.rdoc_files.include('README')
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Sunrise
|
4
|
+
module Deploy
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
7
|
+
desc "Generates capistrano default config"
|
8
|
+
|
9
|
+
def create_capfile
|
10
|
+
copy_file('Capfile', 'Capfile')
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_deploy
|
14
|
+
copy_file('deploy.rb', 'config/deploy.rb')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'sunrise/deploy'
|
2
|
+
|
3
|
+
set :application, "APP_NAME"
|
4
|
+
set :deploy_to, "/var/www/#{application}"
|
5
|
+
set :use_sudo, true
|
6
|
+
set :user, "SERVER_USER"
|
7
|
+
|
8
|
+
set :rvm_ruby_string, 'RUBY_VERSION'
|
9
|
+
|
10
|
+
set :scm, :git
|
11
|
+
set :scm_user, "devfodojo"
|
12
|
+
set :scm_password, "GIT_PASSWORD"
|
13
|
+
set :repository, "#{scm_user}@somehost:~/projects/project.git"
|
14
|
+
set :remote, "#{scm_user}"
|
15
|
+
set :branch, "master"
|
16
|
+
|
17
|
+
server "SERVER_IP", :app, :web, :db, :primary => true
|
18
|
+
|
19
|
+
namespace :app do
|
20
|
+
task :start do
|
21
|
+
run "#{try_sudo} sv start #{application}"
|
22
|
+
end
|
23
|
+
|
24
|
+
task :stop do
|
25
|
+
run "#{try_sudo} sv stop #{application}"
|
26
|
+
end
|
27
|
+
|
28
|
+
task :restart, :roles => :app, :except => { :no_release => true } do
|
29
|
+
run "#{try_sudo} sv restart #{application}"
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'sunrise/deploy/strategy/simple'
|
2
|
+
|
3
|
+
module Capistrano
|
4
|
+
Configuration.instance(true).load do
|
5
|
+
|
6
|
+
# Taken from the capistrano code.
|
7
|
+
def _cset(name, *args, &block)
|
8
|
+
unless exists?(name)
|
9
|
+
set(name, *args, &block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
set :strategy, Sunrise::Deploy::Strategy::Simple.new(self)
|
14
|
+
|
15
|
+
_cset :rails_env, "production"
|
16
|
+
_cset :rvm_ruby_string, '1.9.3'
|
17
|
+
|
18
|
+
_cset :scm, :git
|
19
|
+
_cset :scm_passphrase, Proc.new { Capistrano::CLI.password_prompt("GIT Password for #{scm_user}:") }
|
20
|
+
_cset :scm_verbose, true
|
21
|
+
_cset :branch, "master"
|
22
|
+
|
23
|
+
# Must be set for the password prompt from git to work
|
24
|
+
_cset :ssh_options, { :forward_agent => true }
|
25
|
+
_cset :default_run_options, { :pty => true}
|
26
|
+
|
27
|
+
_cset :rake, "bundle exec rake"
|
28
|
+
|
29
|
+
_cset :asset_precompile, true
|
30
|
+
_cset :asset_env, "RAILS_GROUPS=assets"
|
31
|
+
_cset :assets_prefix, "assets"
|
32
|
+
_cset :assets_role, [:web]
|
33
|
+
|
34
|
+
namespace :app do
|
35
|
+
desc "Update code, bundle install, migrate, assets precompile and restart server"
|
36
|
+
task :deploy do
|
37
|
+
update
|
38
|
+
bundle.install
|
39
|
+
db.migrate
|
40
|
+
assets.precompile if asset_precompile
|
41
|
+
restart
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "Update code on remote hosts"
|
45
|
+
task :update, :except => { :no_release => true } do
|
46
|
+
on_rollback { strategy.rollback! }
|
47
|
+
strategy.deploy!
|
48
|
+
end
|
49
|
+
|
50
|
+
task :start do
|
51
|
+
run "#{try_sudo} sv start #{application}"
|
52
|
+
end
|
53
|
+
|
54
|
+
task :stop do
|
55
|
+
run "#{try_sudo} sv stop #{application}"
|
56
|
+
end
|
57
|
+
|
58
|
+
task :restart, :roles => :app, :except => { :no_release => true } do
|
59
|
+
run "#{try_sudo} sv restart #{application}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Capistrano
|
2
|
+
Configuration.instance(true).load do
|
3
|
+
|
4
|
+
namespace :assets do
|
5
|
+
desc <<-DESC
|
6
|
+
Run the asset precompilation rake task. You can specify the full path \
|
7
|
+
to the rake executable by setting the rake variable. You can also \
|
8
|
+
specify additional environment variables to pass to rake via the \
|
9
|
+
asset_env variable. The defaults are:
|
10
|
+
|
11
|
+
set :rake, "rake"
|
12
|
+
set :rails_env, "production"
|
13
|
+
set :asset_env, "RAILS_GROUPS=assets"
|
14
|
+
DESC
|
15
|
+
task :precompile, :roles => assets_role, :except => { :no_release => true } do
|
16
|
+
run "cd #{deploy_to} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc <<-DESC
|
20
|
+
Run the asset clean rake task. Use with caution, this will delete \
|
21
|
+
all of your compiled assets. You can specify the full path \
|
22
|
+
to the rake executable by setting the rake variable. You can also \
|
23
|
+
specify additional environment variables to pass to rake via the \
|
24
|
+
asset_env variable. The defaults are:
|
25
|
+
|
26
|
+
set :rake, "rake"
|
27
|
+
set :rails_env, "production"
|
28
|
+
set :asset_env, "RAILS_GROUPS=assets"
|
29
|
+
DESC
|
30
|
+
task :clean, :roles => assets_role, :except => { :no_release => true } do
|
31
|
+
run "cd #{deploy_to} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:clean"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Capistrano
|
2
|
+
Configuration.instance(true).load do
|
3
|
+
|
4
|
+
namespace :db do
|
5
|
+
desc <<-DESC
|
6
|
+
Run the migrate rake task. By default, it runs this in most recently \
|
7
|
+
deployed version of the app. However, you can specify a different release \
|
8
|
+
via the migrate_target variable, which must be one of :latest (for the \
|
9
|
+
default behavior), or :current (for the release indicated by the \
|
10
|
+
`current' symlink). Strings will work for those values instead of symbols, \
|
11
|
+
too. You can also specify additional environment variables to pass to rake \
|
12
|
+
via the migrate_env variable. Finally, you can specify the full path to the \
|
13
|
+
rake executable by setting the rake variable. The defaults are:
|
14
|
+
|
15
|
+
set :rake, "rake"
|
16
|
+
set :rails_env, "production"
|
17
|
+
set :migrate_env, ""
|
18
|
+
DESC
|
19
|
+
task :migrate, :roles => :db, :only => { :primary => true } do
|
20
|
+
rake = fetch(:rake, "rake")
|
21
|
+
rails_env = fetch(:rails_env, "production")
|
22
|
+
migrate_env = fetch(:migrate_env, "")
|
23
|
+
|
24
|
+
run "cd #{deploy_to} && #{rake} RAILS_ENV=#{rails_env} #{migrate_env} db:migrate"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Capistrano
|
2
|
+
Configuration.instance(true).load do
|
3
|
+
namespace :sphinx do
|
4
|
+
desc "Generates Configuration file for TS"
|
5
|
+
task :config, :roles => :app do
|
6
|
+
run "cd #{deploy_to} && #{rake_bin} RAILS_ENV=#{rails_env} ts:config"
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Starts TS"
|
10
|
+
task :start, :roles => :app do
|
11
|
+
run "cd #{deploy_to} && #{rake_bin} RAILS_ENV=#{rails_env} ts:start"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Stops TS"
|
15
|
+
task :stop, :roles => :app do
|
16
|
+
run "cd #{deploy_to} && #{rake_bin} RAILS_ENV=#{rails_env} ts:stop"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Rebuild TS"
|
20
|
+
task :rebuild, :roles => :app do
|
21
|
+
run "cd #{deploy_to} && #{rake_bin} RAILS_ENV=#{rails_env} ts:rebuild"
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Indexes TS"
|
25
|
+
task :index, :roles => :app do
|
26
|
+
run "cd #{deploy_to} && #{rake_bin} RAILS_ENV=#{rails_env} ts:in"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'capistrano/recipes/deploy/strategy/remote'
|
2
|
+
|
3
|
+
module Sunrise
|
4
|
+
module Deploy
|
5
|
+
module Strategy
|
6
|
+
class Simple < ::Capistrano::Deploy::Strategy::Remote
|
7
|
+
|
8
|
+
def rollback!
|
9
|
+
# TODO:
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def command
|
15
|
+
@command ||= source.sync(revision, deploy_to)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sunrise-deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Igor Galeta
|
9
|
+
- Pavlo Galeta
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-09-20 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: capistrano
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rvm-capistrano
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: Deploy module for sunrise-cms using capistrano
|
48
|
+
email: galeta.igor@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files:
|
52
|
+
- README.rdoc
|
53
|
+
files:
|
54
|
+
- lib/sunrise-deploy.rb
|
55
|
+
- lib/sunrise/deploy.rb
|
56
|
+
- lib/sunrise/deploy/strategy/simple.rb
|
57
|
+
- lib/sunrise/deploy/version.rb
|
58
|
+
- lib/sunrise/deploy/recipes.rb
|
59
|
+
- lib/sunrise/deploy/recipes/assets.rb
|
60
|
+
- lib/sunrise/deploy/recipes/appication.rb
|
61
|
+
- lib/sunrise/deploy/recipes/sphinx.rb
|
62
|
+
- lib/sunrise/deploy/recipes/db.rb
|
63
|
+
- lib/sunrise/deploy/recipes/bundle.rb
|
64
|
+
- lib/generators/sunrise/deploy/install_generator.rb
|
65
|
+
- lib/generators/sunrise/deploy/templates/deploy.rb
|
66
|
+
- lib/generators/sunrise/deploy/templates/Capfile
|
67
|
+
- lib/generators/sunrise/deploy/USAGE
|
68
|
+
- MIT-LICENSE
|
69
|
+
- Rakefile
|
70
|
+
- README.rdoc
|
71
|
+
homepage: https://github.com/galetahub/sunrise-deploy
|
72
|
+
licenses: []
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project: sunrise-deploy
|
91
|
+
rubygems_version: 1.8.24
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: Deploy for sunrise-cms
|
95
|
+
test_files: []
|