meow-deploy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +1 -0
- data/examples/god.conf +73 -0
- data/lib/meow-deploy/capistrano_integration.rb +85 -0
- data/lib/meow-deploy/version.rb +3 -0
- data/lib/meow-deploy.rb +2 -0
- data/meow-deploy.gemspec +21 -0
- metadata +71 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Kristjan Rang
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Meow::Deploy
|
2
|
+
|
3
|
+
Tasks for deploying to a stack running god, rbenv and whatever rails server
|
4
|
+
|
5
|
+
Has only been tested on Ubuntu 12.04 and 12.10 with ruby 1.9.3-p286 using user-local rbenv install
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install from rubygems:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem install meow-deploy
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Add the library to your `Gemfile`:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
group :development do
|
21
|
+
gem 'meow-deploy', :require => false
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
And load it into your deployment script `config/deploy.rb`:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'meow-deploy'
|
29
|
+
```
|
30
|
+
|
31
|
+
Add necessary hooks:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
after 'deploy:restart', 'god:reload', 'god:restart'
|
35
|
+
```
|
36
|
+
|
37
|
+
Add optional hooks for uploading your .rbenv-vars file if you're using the rbenv-vars plugin:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
after 'deploy:create_symlink', 'secrets:upload', 'secrets:symlink'
|
41
|
+
```
|
42
|
+
|
43
|
+
Create a new configuration file `config/god.conf`.
|
44
|
+
|
45
|
+
Example config - [examples/god.conf](https://github.com/krisrang/meow-deploy/blob/master/examples/god.conf).
|
46
|
+
Please refer to godrb documentation for more examples and configuration options.
|
47
|
+
|
48
|
+
## Configuration
|
49
|
+
|
50
|
+
You can modify any of the following options in your `deploy.rb` config.
|
51
|
+
|
52
|
+
- `rbenv` - Full path to rbenv. Given user is `deploy` defaults to `/home/deploy/.rbenv/bin/rbenv`
|
53
|
+
- `god_sites_path` - Directory where god configs for all apps on the server are symlinked for reloading after reboot. Given user is `deploy` defaults to `/home/deploy/sites/god`
|
54
|
+
- `god_app_path` - App-specific god.conf. Defaults to `#{current_path}/config/god.conf`.
|
55
|
+
- `bundle_flags` - Bundler flags for generating binstubs that use rbenv. Defaults to `--deployment --quiet --binstubs --shebang ruby-local-exec`
|
56
|
+
- `default_environment` - Set PATH to include rbenv. Given user is `deploy` defaults to `{'PATH' => "/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:$PATH"}`
|
57
|
+
|
58
|
+
## License
|
59
|
+
|
60
|
+
See LICENSE file for details.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/examples/god.conf
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# /etc/init/god.conf
|
2
|
+
# Upstart script for managing god running through the deploy user's rbenv setup
|
3
|
+
# Only tested on Ubuntu 12.04, 12.10
|
4
|
+
|
5
|
+
description "God Process Monitoring"
|
6
|
+
author "Christoph Geschwind <christoph@mixxt.net>"
|
7
|
+
|
8
|
+
start on runlevel [2345]
|
9
|
+
stop on runlevel [!2345]
|
10
|
+
|
11
|
+
respawn # respawn the service if it dies
|
12
|
+
respawn limit 5 10 # stop respawning if it fails 5 times in 10 seconds
|
13
|
+
|
14
|
+
pre-start script
|
15
|
+
mkdir -p /var/run/god # create gods pid directory, you might not need this
|
16
|
+
end script
|
17
|
+
|
18
|
+
script
|
19
|
+
# . /home/deploy/.profile # load environment variables
|
20
|
+
echo $$ > /var/run/god/god.pid
|
21
|
+
export RBENV_ROOT="/home/deploy/.rbenv" # set required rbenv variable
|
22
|
+
# launch god via rbenv NOT daemonized, loads a centralized config in /etc/god.conf
|
23
|
+
exec /home/deploy/.rbenv/bin/rbenv exec god -D -c /etc/god.conf
|
24
|
+
|
25
|
+
# could not get this working without the -D flag and any expect behaviour,
|
26
|
+
# see http://upstart.ubuntu.com/cookbook/#expect for more information
|
27
|
+
# this paragraph supported my decision:
|
28
|
+
# "If your daemon has a "don't daemonize" or "run in the foreground" mode, then it's much simpler to use that and not run
|
29
|
+
# with fork following. One issue with that though, is that Upstart will emit the started JOB=yourjob event as soon as it has
|
30
|
+
# executed your daemon, which may be before it has had time to listen for incoming connections or fully initialize."
|
31
|
+
|
32
|
+
end script
|
33
|
+
|
34
|
+
|
35
|
+
# /etc/god.conf
|
36
|
+
# Basic god.conf to load currently configured sites on reboot
|
37
|
+
|
38
|
+
God.load "/home/deploy/sites/god/*.conf"
|
39
|
+
|
40
|
+
# app/config/god.conf
|
41
|
+
# App specific file for god, goes under your app root.
|
42
|
+
# Gets symlinked to god_conf_path
|
43
|
+
|
44
|
+
God.watch do |w|
|
45
|
+
w.name = "app"
|
46
|
+
w.dir = "/home/deploy/sites/app/current"
|
47
|
+
w.interval = 30.seconds
|
48
|
+
w.log = '/home/deploy/sites/app/shared/log/god.log'
|
49
|
+
w.env =
|
50
|
+
{ 'HOME' => "/home/deploy",
|
51
|
+
'RAILS_ENV' => 'production' }
|
52
|
+
|
53
|
+
w.uid = 'deploy'
|
54
|
+
w.gid = 'deploy'
|
55
|
+
|
56
|
+
w.keepalive
|
57
|
+
|
58
|
+
w.start = "bundle exec foreman start -c"
|
59
|
+
|
60
|
+
w.transition(:up, :restart) do |on|
|
61
|
+
on.condition(:memory_usage) do |c|
|
62
|
+
c.above = 300.megabytes
|
63
|
+
c.times = 2
|
64
|
+
c.notify = 'kris'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
w.transition(:up, :start) do |on|
|
69
|
+
on.condition(:process_exits) do |c|
|
70
|
+
c.notify = 'kris'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'capistrano/version'
|
3
|
+
|
4
|
+
module MeowDeploy
|
5
|
+
class MeowDeployIntegration
|
6
|
+
TASKS = [
|
7
|
+
'god:start',
|
8
|
+
'god:stop',
|
9
|
+
'god:restart',
|
10
|
+
'god:reload',
|
11
|
+
'bundle:install',
|
12
|
+
]
|
13
|
+
|
14
|
+
def self.load_into(capistrano_config)
|
15
|
+
capistrano_config.load do
|
16
|
+
before(CapistranoIntegration::TASKS) do
|
17
|
+
_cset(:rbenv) { "/home/#{fetch(:user)}/.rbenv/bin/rbenv" }
|
18
|
+
_cset(:god_sites_path) { "/home/#{fetch(:user)}/sites/god" }
|
19
|
+
_cset(:god_app_path) { "#{current_path}/config/god.conf" }
|
20
|
+
_cset :bundle_flags, "--deployment --quiet --binstubs --shebang ruby-local-exec"
|
21
|
+
_cset(:default_environment) {
|
22
|
+
{'PATH' => "/home/#{fetch(:user)}/.rbenv/shims:/home/#{fetch(:user)}/.rbenv/bin:$PATH"}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
namespace :god do
|
27
|
+
desc "Reload god config"
|
28
|
+
task :reload, :roles => :app, :except => {:no_release => true} do
|
29
|
+
run "ln -nfs #{god_app_path} #{god_sites_path}/#{application}.conf"
|
30
|
+
sudo "#{rbenv} exec god load #{god_sites_path}/#{application}.conf"
|
31
|
+
end
|
32
|
+
|
33
|
+
task :restart, :roles => :app, :except => {:no_release => true} do
|
34
|
+
sudo "#{rbenv} exec god restart #{application}"
|
35
|
+
end
|
36
|
+
|
37
|
+
task :start, :roles => :app do
|
38
|
+
sudo "#{rbenv} exec god start #{application}"
|
39
|
+
end
|
40
|
+
|
41
|
+
task :stop, :roles => :app do
|
42
|
+
sudo "#{rbenv} exec god stop #{application}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
namespace :secrets do
|
47
|
+
desc "Upload env file"
|
48
|
+
task :upload, :roles => :app do
|
49
|
+
top.upload(".rbenv-vars", "#{shared_path}/.env")
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Symlink env file."
|
53
|
+
task :symlink, :roles => :app do
|
54
|
+
run "ln -nfs #{shared_path}/.env #{current_path}/.rbenv-vars"
|
55
|
+
run "ln -nfs #{shared_path}/.env #{current_path}/.env"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
namespace :tail do
|
60
|
+
desc "Tail production log files"
|
61
|
+
task :production, :roles => :app do
|
62
|
+
run "tail -f #{shared_path}/log/production.log" do |channel, stream, data|
|
63
|
+
trap("INT") { puts 'Interupted'; exit 0; }
|
64
|
+
puts "#{data}"
|
65
|
+
break if stream == :err
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "Tail god log files"
|
70
|
+
task :god, :roles => :app do
|
71
|
+
run "tail -f #{shared_path}/log/god.log" do |channel, stream, data|
|
72
|
+
trap("INT") { puts 'Interupted'; exit 0; }
|
73
|
+
puts "#{data}"
|
74
|
+
break if stream == :err
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
if Capistrano::Configuration.instance
|
84
|
+
MeowDeploy::MeowDeployIntegration.load_into(Capistrano::Configuration.instance)
|
85
|
+
end
|
data/lib/meow-deploy.rb
ADDED
data/meow-deploy.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'meow-deploy/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "meow-deploy"
|
8
|
+
gem.version = MeowDeploy::VERSION
|
9
|
+
gem.authors = "Kristjan Rang"
|
10
|
+
gem.email = "mail@kristjanrang.eu"
|
11
|
+
gem.description = %q{Tasks for deploying to a stack running god, rbenv and whatever rails server}
|
12
|
+
gem.summary = %q{Capistrano tasks for a god-rbenv-whatever stack}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'capistrano'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: meow-deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kristjan Rang
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
prerelease: false
|
16
|
+
type: :runtime
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ! '>='
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
name: capistrano
|
30
|
+
description: Tasks for deploying to a stack running god, rbenv and whatever rails
|
31
|
+
server
|
32
|
+
email: mail@kristjanrang.eu
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- examples/god.conf
|
43
|
+
- lib/meow-deploy.rb
|
44
|
+
- lib/meow-deploy/capistrano_integration.rb
|
45
|
+
- lib/meow-deploy/version.rb
|
46
|
+
- meow-deploy.gemspec
|
47
|
+
homepage: ''
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.23
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Capistrano tasks for a god-rbenv-whatever stack
|
71
|
+
test_files: []
|