caprica 0.0.1.alpha
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 +193 -0
- data/Rakefile +1 -0
- data/caprica.gemspec +21 -0
- data/lib/capistrano/caprica.rb +84 -0
- data/lib/capistrano/caprica/one.rb +54 -0
- data/lib/capistrano/caprica/one/deploy.rb +26 -0
- data/lib/capistrano/caprica/six.rb +20 -0
- data/lib/capistrano/caprica/six/after.rb +18 -0
- data/lib/capistrano/caprica/six/before.rb +21 -0
- data/lib/capistrano/caprica/six/callbacks.rb +88 -0
- data/lib/capistrano/caprica/six/error.rb +17 -0
- data/lib/capistrano/caprica/six/logger.rb +59 -0
- data/lib/capistrano/caprica/six/notify.rb +8 -0
- data/lib/capistrano/caprica/six/skip.rb +0 -0
- data/lib/capistrano/caprica/six/spinner.rb +45 -0
- data/lib/capistrano/caprica/task.rb +39 -0
- data/lib/capistrano/caprica/three.rb +2 -0
- data/lib/capistrano/caprica/three/nginx.rb +7 -0
- data/lib/capistrano/caprica/three/nginx/README.md +65 -0
- data/lib/capistrano/caprica/three/nginx/config.rb +0 -0
- data/lib/capistrano/caprica/three/nginx/install.rb +53 -0
- data/lib/capistrano/caprica/three/nginx/reload.rb +0 -0
- data/lib/capistrano/caprica/three/nginx/setup.rb +14 -0
- data/lib/capistrano/caprica/three/nginx/sites_available.rb +0 -0
- data/lib/capistrano/caprica/three/nginx/sites_disable.rb +0 -0
- data/lib/capistrano/caprica/three/nginx/sites_enable.rb +0 -0
- data/lib/capistrano/caprica/tyrol.rb +6 -0
- data/lib/capistrano/caprica/version.rb +10 -0
- metadata +92 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Jean Mertz
|
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,193 @@
|
|
1
|
+
# Caprica
|
2
|
+
|
3
|
+
Extend your Capistrano tasks with frakkin' awesomeness.
|
4
|
+
|
5
|
+
There are currently three known models on Caprica. They each have their
|
6
|
+
own functionality.
|
7
|
+
|
8
|
+
## Models
|
9
|
+
|
10
|
+
### One
|
11
|
+
|
12
|
+
'One' extends the core tasks that come with Capistrano, and adds
|
13
|
+
notifications while running `Cap`.
|
14
|
+
|
15
|
+
It changes this
|
16
|
+
|
17
|
+
```bash
|
18
|
+
$ be cap deploy:check
|
19
|
+
|
20
|
+
triggering load callbacks
|
21
|
+
* 2013-01-09 13:37:01 executing `staging'
|
22
|
+
triggering start callbacks for `deploy:check'
|
23
|
+
* 2013-01-09 13:37:02 executing `multistage:ensure'
|
24
|
+
* 2013-01-09 13:37:03 executing `deploy:check'
|
25
|
+
* executing "test -d /var/www/caprica/releases"
|
26
|
+
servers: ["127.0.0.1"]
|
27
|
+
[root@127.0.0.1] executing command
|
28
|
+
command finished in 90ms
|
29
|
+
* executing "test -w /var/www/caprica"
|
30
|
+
servers: ["127.0.0.1"]
|
31
|
+
[root@127.0.0.1] executing command
|
32
|
+
command finished in 74ms
|
33
|
+
* executing "test -w /var/www/caprica/releases"
|
34
|
+
servers: ["127.0.0.1"]
|
35
|
+
[root@127.0.0.1] executing command
|
36
|
+
command finished in 68ms
|
37
|
+
* executing "which git"
|
38
|
+
servers: ["127.0.0.1"]
|
39
|
+
[root@127.0.0.1] executing command
|
40
|
+
command finished in 74ms
|
41
|
+
* executing "which rsync"
|
42
|
+
servers: ["127.0.0.1"]
|
43
|
+
[root@127.0.0.1] executing command
|
44
|
+
command finished in 68ms
|
45
|
+
* executing "test -w /var/www/caprica/shared"
|
46
|
+
servers: ["127.0.0.1"]
|
47
|
+
[root@127.0.0.1] executing command
|
48
|
+
command finished in 74ms
|
49
|
+
The following dependencies failed. Please check them and try again:
|
50
|
+
--> `/var/www/caprica/releases' does not exist. Please run `cap deploy:setup'. (root@127.0.0.1)
|
51
|
+
--> You do not have permissions to write to `/var/www/caprica'. (root@127.0.0.1)
|
52
|
+
--> You do not have permissions to write to `/var/www/caprica/releases'. (root@127.0.0.1)
|
53
|
+
--> `/var/www/caprica/shared' is not writable (root@127.0.0.1)
|
54
|
+
```
|
55
|
+
|
56
|
+
into this:
|
57
|
+
|
58
|
+
```bash
|
59
|
+
$ be cap deploy:check -vv
|
60
|
+
|
61
|
+
➞ Set the target stage to `staging'. .................. ✓
|
62
|
+
➞ [internal] Ensure that a stage has been selected. ... ✓
|
63
|
+
➞ Test deployment dependencies.
|
64
|
+
executing "test -d /var/www/caprica/releases"
|
65
|
+
executing "test -w /var/www/caprica"
|
66
|
+
executing "test -w /var/www/caprica/releases"
|
67
|
+
executing "which git"
|
68
|
+
executing "which rsync"
|
69
|
+
➞ Test deployment dependencies. ....................... ✘ failed dependencies
|
70
|
+
➞ `/var/www/caprica/releases' does not exist. Please run `cap deploy:setup'. (root@127.0.0.1)
|
71
|
+
➞ You do not have permissions to write to `/var/www/caprica'. (root@127.0.0.1)
|
72
|
+
➞ You do not have permissions to write to `/var/www/caprica/releases'. (root@127.0.0.1)
|
73
|
+
➞ `/var/www/caprica/shared' is not writable (root@127.0.0.1)
|
74
|
+
```
|
75
|
+
|
76
|
+
or this:
|
77
|
+
|
78
|
+
```bash
|
79
|
+
$ cap nginx:install
|
80
|
+
|
81
|
+
➞ Set the target stage to `staging'. .... ✓
|
82
|
+
➞ Test deployment dependencies. ......... ⣾ executing "test -d /var/www/caprica/releases"
|
83
|
+
➞ Test deployment dependencies. ......... ⣽ executing "test -w /var/www/caprica"
|
84
|
+
➞ Test deployment dependencies. ......... ⣻ executing "test -w /var/www/caprica/releases"
|
85
|
+
➞ Test deployment dependencies. ......... ⣻ executing "which git"
|
86
|
+
➞ Test deployment dependencies. ......... ⢿ executing "which rsync"
|
87
|
+
➞ Test deployment dependencies. ......... ✘ failed dependencies
|
88
|
+
➞ `/var/www/graduation/releases' does not exist. Please run `cap deploy:setup'. (root@178.79.130.64)
|
89
|
+
➞ You do not have permissions to write to `/var/www/graduation'. (root@178.79.130.64)
|
90
|
+
➞ You do not have permissions to write to `/var/www/graduation/releases'. (root@178.79.130.64)
|
91
|
+
➞ `/var/www/graduation/shared' is not writable (root@178.79.130.64)
|
92
|
+
```
|
93
|
+
|
94
|
+
*The 'Install nginx' lines will actually replace previous line after each
|
95
|
+
step. resulting in a two line final output:*
|
96
|
+
|
97
|
+
```bash
|
98
|
+
➞ Set the target stage to `staging'. .... ✓
|
99
|
+
➞ Test deployment dependencies. ......... ✘ failed dependencies
|
100
|
+
➞ `/var/www/graduation/releases' does not exist. Please run `cap deploy:setup'. (root@178.79.130.64)
|
101
|
+
➞ You do not have permissions to write to `/var/www/graduation'. (root@178.79.130.64)
|
102
|
+
➞ You do not have permissions to write to `/var/www/graduation/releases'. (root@178.79.130.64)
|
103
|
+
➞ `/var/www/graduation/shared' is not writable (root@178.79.130.64)
|
104
|
+
```
|
105
|
+
|
106
|
+
### Three
|
107
|
+
|
108
|
+
'Three' adds custom tasks to your Capistrano files, these tasks take full
|
109
|
+
advantage of the styling provided by 'Six'.
|
110
|
+
|
111
|
+
Here is a list of the currently supported tasks:
|
112
|
+
|
113
|
+
```
|
114
|
+
nginx:setup
|
115
|
+
nginx:install
|
116
|
+
nginx:reload
|
117
|
+
nginx:config
|
118
|
+
nginx:sites:available
|
119
|
+
nginx:sites:enable
|
120
|
+
nginx:sites:disable
|
121
|
+
```
|
122
|
+
|
123
|
+
For all tasks and their descriptions, see the README in `lib/caprica/three`.
|
124
|
+
|
125
|
+
### Six
|
126
|
+
|
127
|
+
Prettify Capistrano output.
|
128
|
+
|
129
|
+
## Installation
|
130
|
+
|
131
|
+
Add this line to your application's Gemfile:
|
132
|
+
|
133
|
+
gem 'caprica', group: :development
|
134
|
+
|
135
|
+
And then execute:
|
136
|
+
|
137
|
+
$ bundle
|
138
|
+
|
139
|
+
Or install it yourself as:
|
140
|
+
|
141
|
+
$ gem install caprica
|
142
|
+
|
143
|
+
## Usage
|
144
|
+
|
145
|
+
Add this line to your Capfile:
|
146
|
+
|
147
|
+
require 'capistrano/caprica'
|
148
|
+
|
149
|
+
If you want to specify which parts you want to load, you can do so:
|
150
|
+
|
151
|
+
require 'capistrano/caprica/one' # extends core Capistrano tasks with 'six'
|
152
|
+
require 'capistrano/caprica/three' # add custom tasks which work with 'six'
|
153
|
+
require 'capistrano/caprica/six' # beatifies Capistrano output
|
154
|
+
|
155
|
+
While 'three' gives you a lot of custom tasks, you might want to narrow
|
156
|
+
down the ones that are loaded:
|
157
|
+
|
158
|
+
require 'capistrano/caprica/three/nginx'
|
159
|
+
require 'capistrano/caprica/three/postgresql'
|
160
|
+
require 'capistrano/caprica/three/sidekiq'
|
161
|
+
|
162
|
+
## Contributing
|
163
|
+
|
164
|
+
1. Fork it
|
165
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
166
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
167
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
168
|
+
5. Create new Pull Request
|
169
|
+
|
170
|
+
## License
|
171
|
+
|
172
|
+
Copyright (c) 2012-2013 Jean Mertz
|
173
|
+
|
174
|
+
MIT License
|
175
|
+
|
176
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
177
|
+
a copy of this software and associated documentation files (the
|
178
|
+
"Software"), to deal in the Software without restriction, including
|
179
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
180
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
181
|
+
permit persons to whom the Software is furnished to do so, subject to
|
182
|
+
the following conditions:
|
183
|
+
|
184
|
+
The above copyright notice and this permission notice shall be
|
185
|
+
included in all copies or substantial portions of the Software.
|
186
|
+
|
187
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
188
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
189
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
190
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
191
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
192
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
193
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/caprica.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 'capistrano/caprica/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'caprica'
|
8
|
+
gem.version = Caprica::VERSION::STRING
|
9
|
+
gem.authors = ['Jean Mertz']
|
10
|
+
gem.email = ['jean@mertz.fm']
|
11
|
+
gem.description = %q{Extend your Capistrano tasks with frakkin' awesomeness.}
|
12
|
+
gem.summary = %q{Prettify output, enhance existing tasks, extend with custom tasks.}
|
13
|
+
gem.homepage = 'https://github.com/JeanMertz/Caprica'
|
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{^(spec|features)/})
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_dependency 'capistrano'
|
21
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
class Caprica
|
2
|
+
require 'pp'
|
3
|
+
require 'capistrano/caprica/version'
|
4
|
+
require 'capistrano/caprica/task'
|
5
|
+
require 'capistrano/caprica/one'
|
6
|
+
# require 'caprica/three'
|
7
|
+
require 'capistrano/caprica/six'
|
8
|
+
|
9
|
+
require 'colored'
|
10
|
+
|
11
|
+
|
12
|
+
attr_reader :task, :logger, :spinner, :one, :six
|
13
|
+
|
14
|
+
@@active_instance = nil
|
15
|
+
@verbose = true if ARGV.any? { |v| v =~ /-[v]{2,}/ }
|
16
|
+
|
17
|
+
def initialize task
|
18
|
+
@task = Caprica::Task.new(task)
|
19
|
+
@logger = Caprica::Six::Logger.new(self)
|
20
|
+
@spinner = Caprica::Six::Spinner.new(self)
|
21
|
+
@silence = false
|
22
|
+
|
23
|
+
@@active_instance = self
|
24
|
+
|
25
|
+
# activate cylons
|
26
|
+
@one = Caprica::One.new(self) if defined? Caprica::One
|
27
|
+
@six = Caprica::Six.new(self) if defined? Caprica::Six
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.active_instance
|
31
|
+
@@active_instance
|
32
|
+
end
|
33
|
+
|
34
|
+
def before
|
35
|
+
@six.before if defined? @six
|
36
|
+
end
|
37
|
+
|
38
|
+
def after
|
39
|
+
@six.after if defined? @six
|
40
|
+
end
|
41
|
+
|
42
|
+
def silence!
|
43
|
+
@silence = true
|
44
|
+
end
|
45
|
+
|
46
|
+
def silenced?
|
47
|
+
@silence
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.verbose
|
51
|
+
@verbose ? true : false
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.verbose= value
|
55
|
+
@verbose = value
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
Capistrano::Configuration.instance(true).load do
|
60
|
+
@skip_carpica = true if ARGV.include? '-v'
|
61
|
+
|
62
|
+
next if @skip_carpica
|
63
|
+
|
64
|
+
on :before do
|
65
|
+
@caprica = Caprica.new(current_task)
|
66
|
+
@caprica.before
|
67
|
+
end
|
68
|
+
|
69
|
+
on :after do
|
70
|
+
@caprica.after
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
class Array
|
76
|
+
def inject(n)
|
77
|
+
each { |value| n = yield(n, value) }
|
78
|
+
n
|
79
|
+
end
|
80
|
+
|
81
|
+
def rsend(baseobj)
|
82
|
+
inject(baseobj) { |n, value| n.send(value) }
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'capistrano/caprica/six'
|
2
|
+
require 'capistrano/caprica/one/deploy'
|
3
|
+
|
4
|
+
class Caprica::One
|
5
|
+
include Caprica::One::Deploy
|
6
|
+
|
7
|
+
def initialize caprica
|
8
|
+
@caprica = caprica
|
9
|
+
end
|
10
|
+
|
11
|
+
def verbose_debugger message
|
12
|
+
msg_opts = {
|
13
|
+
styling: :black,
|
14
|
+
clear_line: true,
|
15
|
+
dots: false,
|
16
|
+
prefix: ' '
|
17
|
+
}
|
18
|
+
|
19
|
+
case @caprica.logger.notice
|
20
|
+
when nil
|
21
|
+
@caprica.spinner.stop
|
22
|
+
@caprica.logger.puts clear_line: true, dots: false
|
23
|
+
when /^executing ".*"/
|
24
|
+
@caprica.logger.puts msg_opts.merge(msg: @caprica.logger.notice)
|
25
|
+
end
|
26
|
+
|
27
|
+
@caprica.logger.notice = message
|
28
|
+
@caprica.logger.print msg_opts.merge(msg: message)
|
29
|
+
end
|
30
|
+
|
31
|
+
def inline_debugger message
|
32
|
+
@caprica.spinner.start message
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module ::Capistrano
|
37
|
+
class Logger
|
38
|
+
|
39
|
+
alias_method :debug_internal, :debug
|
40
|
+
def debug(message, line_prefix=nil)
|
41
|
+
@caprica = Caprica.active_instance
|
42
|
+
|
43
|
+
if ! @caprica || @caprica.silenced? || message =~ /^executing command$/
|
44
|
+
return debug_internal(message, line_prefix)
|
45
|
+
end
|
46
|
+
|
47
|
+
if Caprica.verbose
|
48
|
+
@caprica.one.verbose_debugger(message)
|
49
|
+
else
|
50
|
+
@caprica.one.inline_debugger(message)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Caprica::One
|
2
|
+
module Deploy
|
3
|
+
|
4
|
+
module ::Capistrano
|
5
|
+
class Configuration
|
6
|
+
module Namespaces
|
7
|
+
class Namespace
|
8
|
+
|
9
|
+
def puts content
|
10
|
+
@caprica = Caprica.active_instance
|
11
|
+
return super unless @caprica
|
12
|
+
|
13
|
+
if content.include? 'The following dependencies failed.'
|
14
|
+
@caprica.six.error notice: 'failed dependencies', continue: true
|
15
|
+
else
|
16
|
+
content.gsub!('--> ', '')
|
17
|
+
@caprica.logger.puts msg: content, length: false, styling: :white, dots: false, prefix: ["\u279E".red, ' ']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'capistrano/caprica/six/before'
|
2
|
+
require 'capistrano/caprica/six/after'
|
3
|
+
require 'capistrano/caprica/six/logger'
|
4
|
+
require 'capistrano/caprica/six/spinner'
|
5
|
+
require 'capistrano/caprica/six/error.rb'
|
6
|
+
# require 'caprica/six/prettify.rb'
|
7
|
+
# require 'caprica/six/callbacks.rb'
|
8
|
+
# require 'caprica/six/notify.rb'
|
9
|
+
# require 'caprica/six/skip.rb'
|
10
|
+
# require 'caprica/six/succeed.rb'
|
11
|
+
|
12
|
+
class Caprica::Six
|
13
|
+
include Caprica::Six::Before
|
14
|
+
include Caprica::Six::After
|
15
|
+
include Caprica::Six::Error
|
16
|
+
|
17
|
+
def initialize caprica
|
18
|
+
@caprica = caprica
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Caprica::Six
|
2
|
+
module After
|
3
|
+
|
4
|
+
def after
|
5
|
+
successful unless @caprica.task.failed? || @caprica.silenced?
|
6
|
+
|
7
|
+
# don't show any more output for this task after completion
|
8
|
+
@caprica.silence!
|
9
|
+
end
|
10
|
+
|
11
|
+
def successful
|
12
|
+
@caprica.task.success!
|
13
|
+
@caprica.spinner.stop
|
14
|
+
@caprica.logger.puts styling: :green, clear_line: true, status: :done
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Caprica::Six
|
2
|
+
module Before
|
3
|
+
|
4
|
+
def before
|
5
|
+
@caprica.task.internal? && ! Caprica.verbose ? stop : start
|
6
|
+
end
|
7
|
+
|
8
|
+
def after
|
9
|
+
finish unless @caprica.silenced?
|
10
|
+
end
|
11
|
+
|
12
|
+
def stop
|
13
|
+
@caprica.silence!
|
14
|
+
end
|
15
|
+
|
16
|
+
def start
|
17
|
+
@caprica.logger.print styling: :white, append: ' '
|
18
|
+
@caprica.spinner.start
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# module Caprica
|
2
|
+
# module Six
|
3
|
+
# module Callbacks
|
4
|
+
|
5
|
+
# def initialize
|
6
|
+
# @hide_task_output = false
|
7
|
+
# @tasks_without_callbacks = ['nginx:setup']
|
8
|
+
# end
|
9
|
+
|
10
|
+
# def before
|
11
|
+
# Capistrano::Configuration.instance.load do
|
12
|
+
# on :before, except: tasks_without_callbacks do
|
13
|
+
# Caprica::Six.start(current_task)
|
14
|
+
# end
|
15
|
+
|
16
|
+
# on :after, except: tasks_without_callbacks do
|
17
|
+
# Caprica::Six.finish(current_task) if show_output?
|
18
|
+
# end
|
19
|
+
|
20
|
+
# def internal_task?
|
21
|
+
# current_task.desc.include?('[internal]')
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
|
25
|
+
# end
|
26
|
+
|
27
|
+
# def after
|
28
|
+
# Capistrano::Configuration.instance.load do
|
29
|
+
# on :after, except: tasks_without_callbacks do
|
30
|
+
# Caprica::Six.succeed if show_output?
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
|
35
|
+
|
36
|
+
# Capistrano::Configuration.instance.load do
|
37
|
+
# on :before, except: tasks_without_callbacks do
|
38
|
+
# Caprica::Six::Callbacks.start
|
39
|
+
# return hide_task_output if internal_task?
|
40
|
+
|
41
|
+
# @description = current_task.desc
|
42
|
+
|
43
|
+
# pprint styling: :white, trailing_whitespace: true
|
44
|
+
# spinner :start
|
45
|
+
# end
|
46
|
+
|
47
|
+
# on :after, except: tasks_without_callbacks do
|
48
|
+
# Caprica::Six.succeed if show_output?
|
49
|
+
# end
|
50
|
+
|
51
|
+
# def internal_task?
|
52
|
+
# current_task.desc.include?('[internal]')
|
53
|
+
# end
|
54
|
+
# end
|
55
|
+
|
56
|
+
# private
|
57
|
+
|
58
|
+
# def show_output?
|
59
|
+
# !! @hide_task_output
|
60
|
+
# end
|
61
|
+
|
62
|
+
# def tasks_without_callbacks
|
63
|
+
# @tasks_without_callbacks
|
64
|
+
# end
|
65
|
+
|
66
|
+
# end
|
67
|
+
# end
|
68
|
+
# end
|
69
|
+
|
70
|
+
|
71
|
+
# Capistrano::Configuration.instance.load do
|
72
|
+
# on :before, except: skip_callbacks do
|
73
|
+
# unset :cap_task_unsuccessful
|
74
|
+
# @hide_task_output = false
|
75
|
+
# if ! current_task.desc || current_task.desc.include?('[internal]')
|
76
|
+
# @hide_task_output = true
|
77
|
+
# else
|
78
|
+
# @start_msg = current_task.desc
|
79
|
+
# pprint @start_msg, styling: :white, trailing_whitespace: true
|
80
|
+
# start_spinner
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
|
84
|
+
# on :after, except: skip_callbacks do
|
85
|
+
# succeeded unless @hide_task_output
|
86
|
+
# end
|
87
|
+
|
88
|
+
# end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Caprica::Six
|
2
|
+
module Error
|
3
|
+
|
4
|
+
def error opts = {}
|
5
|
+
@caprica.task.failed!
|
6
|
+
@caprica.spinner.stop
|
7
|
+
|
8
|
+
print_error opts
|
9
|
+
end
|
10
|
+
|
11
|
+
def print_error opts = {}
|
12
|
+
@caprica.logger.puts styling: :red, notice: opts[:notice], clear_line: true, status: :error
|
13
|
+
abort unless opts[:continue]
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class Caprica::Six
|
2
|
+
class Logger
|
3
|
+
|
4
|
+
attr_accessor :notice
|
5
|
+
|
6
|
+
def initialize(caprica)
|
7
|
+
@caprica = caprica
|
8
|
+
end
|
9
|
+
|
10
|
+
def print opts = {}
|
11
|
+
::Kernel.print(parser opts)
|
12
|
+
end
|
13
|
+
|
14
|
+
def puts opts = {}
|
15
|
+
::Kernel.puts(parser opts)
|
16
|
+
end
|
17
|
+
|
18
|
+
def string opts = {}
|
19
|
+
parser opts
|
20
|
+
end
|
21
|
+
|
22
|
+
def parser opts = {}
|
23
|
+
opts = {
|
24
|
+
length: terminal_width/2.3, # [False, Integer]
|
25
|
+
styling: [], # [Array, :red, :green, :blue, :bold, etc...]
|
26
|
+
clear_line: false, # [False, True]
|
27
|
+
prefix: ["\u279E".white, ' '], # [False, String, Array]
|
28
|
+
dots: true, # [True, False]
|
29
|
+
status: nil, # [False, String, :done, :error, :skipped]
|
30
|
+
notice: nil, # [False, String]
|
31
|
+
append: nil # [Nill, String]
|
32
|
+
}.merge(opts)
|
33
|
+
|
34
|
+
msg = opts.fetch(:msg, @caprica.task.description.strip)
|
35
|
+
msg = msg[0, opts[:length]] if opts[:length]
|
36
|
+
dots_width = terminal_width/2 - msg.length
|
37
|
+
|
38
|
+
m = []
|
39
|
+
m << ["\r","\e[K"] if opts[:clear_line]
|
40
|
+
m << [opts[:prefix]] if opts[:prefix]
|
41
|
+
m << [[opts[:styling]].flatten.rsend(msg)]
|
42
|
+
m << [' ', ('.' * dots_width).black] if opts[:dots]
|
43
|
+
m << [' ', "\u2713".green] if opts[:status] == :done
|
44
|
+
m << [' ', "\u2718".red] if opts[:status] == :error
|
45
|
+
m << [' ', "\u273B".yellow] if opts[:status] == :skipped
|
46
|
+
m << [' ', opts[:status].yellow] if opts[:status].is_a? String
|
47
|
+
m << [' ', opts[:notice].black] if opts[:notice]
|
48
|
+
m << [opts[:append]] if opts[:append]
|
49
|
+
|
50
|
+
m.flatten.join('')
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def terminal_width
|
56
|
+
`stty size | cut -d' ' -f2`.to_i
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
class Caprica::Six
|
3
|
+
class Spinner
|
4
|
+
|
5
|
+
def initialize caprica
|
6
|
+
@caprica = caprica
|
7
|
+
@chars = %w[⣾ ⣽ ⣻ ⢿ ⡿ ⣟ ⣯ ⣷]
|
8
|
+
@running = false
|
9
|
+
end
|
10
|
+
|
11
|
+
def start notice = false
|
12
|
+
stop
|
13
|
+
@notice = notice
|
14
|
+
@running = true
|
15
|
+
spinner :wakeup
|
16
|
+
end
|
17
|
+
|
18
|
+
def stop
|
19
|
+
@notice = false
|
20
|
+
@running = false
|
21
|
+
sleep 0.1
|
22
|
+
end
|
23
|
+
|
24
|
+
def spinner action
|
25
|
+
Thread.new do
|
26
|
+
loop do
|
27
|
+
if ! @running
|
28
|
+
Thread.stop
|
29
|
+
end
|
30
|
+
|
31
|
+
if @notice
|
32
|
+
@caprica.logger.print notice: @notice, status: @chars[0].bold.yellow, clear_line: true
|
33
|
+
sleep 0.1
|
34
|
+
else
|
35
|
+
print @chars[0].bold.yellow
|
36
|
+
sleep 0.1
|
37
|
+
print "\b"
|
38
|
+
end
|
39
|
+
@chars.push @chars.shift
|
40
|
+
end
|
41
|
+
end.send(action)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Caprica::Task
|
2
|
+
|
3
|
+
def initialize(current_task)
|
4
|
+
@cap_task = current_task
|
5
|
+
@success = false
|
6
|
+
@failure = false
|
7
|
+
end
|
8
|
+
|
9
|
+
def current
|
10
|
+
@cap_task
|
11
|
+
end
|
12
|
+
|
13
|
+
def description
|
14
|
+
@cap_task.brief_description
|
15
|
+
end
|
16
|
+
|
17
|
+
def internal?
|
18
|
+
description.include?('[internal]')
|
19
|
+
end
|
20
|
+
|
21
|
+
def failed!
|
22
|
+
@success = false && @success.freeze
|
23
|
+
@failure = true && @failure.freeze
|
24
|
+
end
|
25
|
+
|
26
|
+
def failed?
|
27
|
+
@failed && ! @success
|
28
|
+
end
|
29
|
+
|
30
|
+
def success!
|
31
|
+
@success = true && @success.freeze
|
32
|
+
@failure = false && @failure.freeze
|
33
|
+
end
|
34
|
+
|
35
|
+
def success?
|
36
|
+
@success && ! @failed
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'caprica/three/nginx/setup'
|
2
|
+
require 'caprica/three/nginx/install'
|
3
|
+
require 'caprica/three/nginx/reload'
|
4
|
+
require 'caprica/three/nginx/config'
|
5
|
+
require 'caprica/three/nginx/sites_available'
|
6
|
+
require 'caprica/three/nginx/sites_enable'
|
7
|
+
require 'caprica/three/nginx/sites_disable'
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# nginx
|
2
|
+
|
3
|
+
Install and manage your nginx server.
|
4
|
+
|
5
|
+
## nginx:install - install nginx on remote server
|
6
|
+
|
7
|
+
configuration variables:
|
8
|
+
|
9
|
+
```
|
10
|
+
nginx_install_role # default: web
|
11
|
+
nginx_sites_available_path # default: /var/nginx/sites-available
|
12
|
+
nginx_sites_enable_path # default: /var/nginx/sites-enabled
|
13
|
+
```
|
14
|
+
|
15
|
+
## nginx:reload - reload nginx configuration
|
16
|
+
|
17
|
+
The `nginx:reload` command reloads the nginx configuration without
|
18
|
+
actually restarting the server. This allows active sites to continue
|
19
|
+
functioning correctly, while you can start and stop specific sites using
|
20
|
+
`nginx:sites:enable` and `nginx:sites:disable`.
|
21
|
+
|
22
|
+
Note that this command is automatically run after the above two tasks.
|
23
|
+
|
24
|
+
configuration variables:
|
25
|
+
|
26
|
+
```
|
27
|
+
nginx_reload_role # default: web
|
28
|
+
```
|
29
|
+
|
30
|
+
|
31
|
+
## nginx:config - upload global configuration file
|
32
|
+
|
33
|
+
configuration variables:
|
34
|
+
|
35
|
+
```
|
36
|
+
nginx_config_role # default: web
|
37
|
+
nginx_config_source # default: asks for path/url
|
38
|
+
nginx_config_path # default: /etc/nginx/nginx.conf
|
39
|
+
```
|
40
|
+
|
41
|
+
## nginx:sites:available - upload site configuration file
|
42
|
+
|
43
|
+
configuration variables:
|
44
|
+
|
45
|
+
```
|
46
|
+
nginx_sites_available_role # default: web
|
47
|
+
nginx_sites_available_source # default: asks for path/url
|
48
|
+
```
|
49
|
+
|
50
|
+
## nginx:sites:enable - enable site configuration file
|
51
|
+
|
52
|
+
configuration variables:
|
53
|
+
|
54
|
+
```
|
55
|
+
nginx_sites_enable_role # default: web
|
56
|
+
nginx_sites_enable_source # default: asks for path/url
|
57
|
+
```
|
58
|
+
|
59
|
+
## nginx:sites:disable - disable site configuration file
|
60
|
+
|
61
|
+
configuration variables:
|
62
|
+
|
63
|
+
```
|
64
|
+
nginx_sites_disable_role # default: web
|
65
|
+
```
|
File without changes
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'open-uri'
|
3
|
+
# Set OpenURI buffer to 0, always create FileIO instead of StringIO
|
4
|
+
OpenURI::Buffer.send :remove_const, 'StringMax' if OpenURI::Buffer.const_defined?('StringMax')
|
5
|
+
OpenURI::Buffer.const_set 'StringMax', 0
|
6
|
+
|
7
|
+
Capistrano::Configuration.instance.load do
|
8
|
+
default_run_options[:pty] = true
|
9
|
+
|
10
|
+
namespace :nginx do
|
11
|
+
desc 'Install nginx'
|
12
|
+
task :install, role: -> { fetch :nginx_install_role, :web_root } do
|
13
|
+
transaction do
|
14
|
+
# break if already installed
|
15
|
+
break skip('nginx already installed') if remote_file_exists? '/etc/init.d/nginx'
|
16
|
+
|
17
|
+
# set rollback instructions
|
18
|
+
on_rollback do
|
19
|
+
error
|
20
|
+
run "rm -rf /etc/apt/sources.list.d/nginx"
|
21
|
+
run 'apt-get -y purge nginx'
|
22
|
+
run "rm -rf #{fetch :nginx_sites_available_path, '/var/nginx/sites-available'}"
|
23
|
+
run "rm -rf #{fetch :nginx_sites_enable_path, '/var/nginx/sites-enabled'}"
|
24
|
+
run %Q{apt-key remove `apt-key list | grep 'nginx' -b1 | grep -Eo '[0-9A-Z]{6,}'`}
|
25
|
+
end
|
26
|
+
|
27
|
+
# add nginx package repository signed key to apt-key
|
28
|
+
notify 'downloading nginx package signed key'
|
29
|
+
run 'curl http://nginx.org/packages/keys/nginx_signing.key | apt-key add -'
|
30
|
+
#run "curl http://nginx.org/packages/keys/nginx_signing.key | #{try_sudo} apt-key add -"
|
31
|
+
|
32
|
+
# set-up official package repository sources
|
33
|
+
sources = "deb http://nginx.org/packages/debian/ squeeze nginx\n
|
34
|
+
deb-src http://nginx.org/packages/debian/ squeeze nginx"
|
35
|
+
notify 'adding official nginx repository to apt sources'
|
36
|
+
put sources, '/etc/apt/sources.list.d/nginx'
|
37
|
+
|
38
|
+
# update sources content
|
39
|
+
notify 'updating apt sources content'
|
40
|
+
run 'apt-get -y update'
|
41
|
+
|
42
|
+
# install latest nginx release
|
43
|
+
notify 'installing nginx from apt-get'
|
44
|
+
run 'apt-get install nginx'
|
45
|
+
|
46
|
+
# create sites-available and sites-enabled
|
47
|
+
notify 'creating sites-available and sites-enabled'
|
48
|
+
run "mkdir -p #{fetch :nginx_sites_available_path, '/var/nginx/sites-available'}"
|
49
|
+
run "mkdir -p #{fetch :nginx_sites_enable_path, '/var/nginx/sites-enabled'}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
default_run_options[:pty] = true
|
3
|
+
|
4
|
+
namespace :nginx do
|
5
|
+
task :setup, role: -> { fetch :nginx_setup_role, :web } do
|
6
|
+
transaction do
|
7
|
+
top.nginx.install
|
8
|
+
top.nginx.config
|
9
|
+
top.nginx.sites.available
|
10
|
+
top.nginx.sites.enable
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: caprica
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jean Mertz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Extend your Capistrano tasks with frakkin' awesomeness.
|
31
|
+
email:
|
32
|
+
- jean@mertz.fm
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- caprica.gemspec
|
43
|
+
- lib/capistrano/caprica.rb
|
44
|
+
- lib/capistrano/caprica/one.rb
|
45
|
+
- lib/capistrano/caprica/one/deploy.rb
|
46
|
+
- lib/capistrano/caprica/six.rb
|
47
|
+
- lib/capistrano/caprica/six/after.rb
|
48
|
+
- lib/capistrano/caprica/six/before.rb
|
49
|
+
- lib/capistrano/caprica/six/callbacks.rb
|
50
|
+
- lib/capistrano/caprica/six/error.rb
|
51
|
+
- lib/capistrano/caprica/six/logger.rb
|
52
|
+
- lib/capistrano/caprica/six/notify.rb
|
53
|
+
- lib/capistrano/caprica/six/skip.rb
|
54
|
+
- lib/capistrano/caprica/six/spinner.rb
|
55
|
+
- lib/capistrano/caprica/task.rb
|
56
|
+
- lib/capistrano/caprica/three.rb
|
57
|
+
- lib/capistrano/caprica/three/nginx.rb
|
58
|
+
- lib/capistrano/caprica/three/nginx/README.md
|
59
|
+
- lib/capistrano/caprica/three/nginx/config.rb
|
60
|
+
- lib/capistrano/caprica/three/nginx/install.rb
|
61
|
+
- lib/capistrano/caprica/three/nginx/reload.rb
|
62
|
+
- lib/capistrano/caprica/three/nginx/setup.rb
|
63
|
+
- lib/capistrano/caprica/three/nginx/sites_available.rb
|
64
|
+
- lib/capistrano/caprica/three/nginx/sites_disable.rb
|
65
|
+
- lib/capistrano/caprica/three/nginx/sites_enable.rb
|
66
|
+
- lib/capistrano/caprica/tyrol.rb
|
67
|
+
- lib/capistrano/caprica/version.rb
|
68
|
+
homepage: https://github.com/JeanMertz/Caprica
|
69
|
+
licenses: []
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>'
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.3.1
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.8.23
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: Prettify output, enhance existing tasks, extend with custom tasks.
|
92
|
+
test_files: []
|