mascherano 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjhmZDVkMTczM2ZkYzkwMjVjZDdhZmI1MjEzYWFiZThmNmFjNWZkMA==
4
+ M2VjYjVlOTY0Y2NjZGFkZmQ1MDM5NTRkOTM3M2Q3NzgxZGVjYjMzZg==
5
5
  data.tar.gz: !binary |-
6
- MjhhMzJjYWQzMmU5NzcxNTFkYzBkODFjYzVjMTQwOTBiOWQ3ZjYxMQ==
6
+ YzVmYjY1ZjgwNGQ0OTY4ZGJlMzZkYWY0YThmOGFiZmE2YzA0NTlhYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjBmMmY3MTJhNTJhYTk4YWVkYzcxOWM1OTM1NGU5ZTNhNDRjNjczZGE5NmQy
10
- Y2QwNGFkNjBhOTIyODk3MzM1MGRjY2E0ZDczNDNjYWY0OWU2MzQ1NmQ0Y2Ux
11
- MzQ0ZjViMTgzYzFiYjcwMTk1YjM2YTIzNDU1MjljNzAxZjI3ZDA=
9
+ ZjYwMDNjZjAwODJjZmNjZDFhYWQ5NTQ3NTlkNDU1ZjJiZWJiYWIzMTZlNGQ4
10
+ YTczN2E4YjJiZjcyYTI1MmFlZDIzZDQ4MjUzYTU5ZWM1YTIwYTQ3NzUzOTAx
11
+ YmM3M2I1ODEyNWQyNWJkNWMzNWFjM2VkNDZiN2ZlM2MxMmQ3M2U=
12
12
  data.tar.gz: !binary |-
13
- ZTM2NWVkZmUxZDdkNjYzZDVhODk5ZmViODQyZjkzYjFlNGU1MGU2MWRmNzBk
14
- YzUzZTBhNzI3ODNkZTZjZDQ3YmZkZmEyN2RiMjFhZGI5ODhiYmQzNjNlNzM5
15
- YjYyYmVlY2JjODliZGIwMGI2NjgxYWVkMTZmMTgxMzQ1MmUzYWU=
13
+ Nzg1MDQ4ODMzZjQwOGQzNmJkMTZmMjFiYjg1Yzg5MjFlMzZiNGFiZWUwZGZl
14
+ ODQ0ODIzYTQwYmVmODdmZjg0MmM0YTk1NWRlYjY2ZDdmNWZmOTNlODVlMmNj
15
+ ZWY5MTA5ZDU5NTI1MmI5NjU0ZDI5ZmI2YmExZjFhMWNhMGUwYmE=
data/README.md CHANGED
@@ -38,6 +38,7 @@ Mascherano currently have several recipes:
38
38
  | __token__ | Manage and generate random secret token |
39
39
  | __passenger__ | Manage Pushion Passenger based application |
40
40
  | __auth_basic__ | Manage and generate HTTP basic authentication `.htpasswd` |
41
+ | __supervisor__ | Manage applications through supervisor process manager |
41
42
  | _more to come_ | _pull request are welcome ;)_ |
42
43
 
43
44
  This package also provides a `noscm` recipe for when you don't need source code on your deployment box (usually application already compiled).
@@ -59,6 +60,7 @@ require 'mascherano/upstart'
59
60
  require 'mascherano/token'
60
61
  require 'mascherano/passenger'
61
62
  require 'mascherano/auth_basic'
63
+ require 'mascherano/supervisor'
62
64
  ```
63
65
 
64
66
  Then on `config/deploy/{env}.rb` you can customize the options:
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/supervisor.cap', __FILE__)
@@ -6,7 +6,7 @@ namespace :auth_basic do
6
6
  htpasswd = nil
7
7
 
8
8
  run_locally do
9
- htpasswd = execute(:htpasswd, '-nb', fetch(:auth_basic_user), passwd).stdout
9
+ htpasswd = capture(:htpasswd, '-nb', fetch(:auth_basic_user), passwd)
10
10
  htpasswd.chomp!
11
11
  end
12
12
 
@@ -23,7 +23,7 @@ namespace :figaro do
23
23
  figaro_cmd = %Q(Figaro.env("#{figaro_stage}").to_yaml)
24
24
  end
25
25
 
26
- figaro_data = execute(:rails, "runner 'puts #{figaro_cmd}'").stdout
26
+ figaro_data = capture(:rails, "runner 'puts #{figaro_cmd}'")
27
27
  end
28
28
 
29
29
  if figaro_data
@@ -0,0 +1,94 @@
1
+ require 'figaro'
2
+ require 'erb'
3
+ require 'pry'
4
+
5
+ class SupervisorConf < OpenStruct
6
+ def render(template)
7
+ ERB.new(template).result(binding)
8
+ end
9
+
10
+ def render_file(template_file)
11
+ render(File.read(template_file))
12
+ end
13
+
14
+ def env_pair
15
+ self.marshal_dump.map { |key, val| %Q[#{key}="#{val}"] }.join(",\n ")
16
+ end
17
+ end
18
+
19
+ namespace :supervisor do
20
+ desc 'Export supervisor configuration'
21
+ task :export do
22
+ supervisor_config = nil
23
+
24
+ run_locally do
25
+ figaro_cmd = %Q(Figaro.env("#{fetch(:supervisor_stage)}").to_yaml)
26
+ figaro_data = capture(:rails, "runner 'puts #{figaro_cmd}'")
27
+ data = YAML.load(figaro_data)
28
+
29
+ template = SupervisorConf.new(data)
30
+ supervisor_config = template.render_file(fetch(:supervisor_template))
31
+ end
32
+
33
+ if supervisor_config
34
+ on roles(fetch(:supervisor_roles)) do
35
+ upload! StringIO.new(supervisor_config), fetch(:supervisor_target)
36
+ end
37
+ end
38
+ end
39
+
40
+ desc 'Symlink supervisord config to the conf.d'
41
+ task :symlink do
42
+ on roles(fetch(:supervisor_roles)) do
43
+ execute :ln, '-sf', fetch(:supervisor_target), fetch(:supervisor_confd)
44
+ end
45
+ end
46
+
47
+ desc 'Reread supervisord'
48
+ task :reread do
49
+ on roles(fetch(:supervisor_roles)) do
50
+ execute :supervisorctl, 'reread'
51
+ end
52
+ end
53
+
54
+ desc 'Update supervisord'
55
+ task :update do
56
+ on roles(fetch(:supervisor_roles)) do
57
+ execute :supervisorctl, 'update'
58
+ end
59
+ end
60
+
61
+ desc 'Restart application'
62
+ task :restart do
63
+ on roles(fetch(:supervisor_roles)) do
64
+ execute :supervisorctl, 'restart', "#{fetch(:supervisor_application)}:*"
65
+ end
66
+ end
67
+
68
+ desc 'Update configuration or restart application'
69
+ task :refresh do
70
+ on roles(fetch(:supervisor_roles)) do
71
+ if test "supervisorctl reread | grep 'No config updates to processes'"
72
+ execute :supervisorctl, 'restart', "#{fetch(:supervisor_application)}:*"
73
+ else
74
+ execute :supervisorctl, 'update'
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ namespace :load do
81
+ task :defaults do
82
+ set :supervisor_application, -> { fetch(:application) }
83
+ set :supervisor_stage, -> { fetch(:stage) }
84
+ set :supervisor_template, -> { "config/supervisor/#{fetch(:supervisor_stage)}.conf" }
85
+ set :supervisor_target, -> { shared_path.join('supervisord.conf') }
86
+ set :supervisor_confd, -> { "/etc/supervisor/conf.d/#{fetch(:supervisor_application)}.conf" }
87
+ set :supervisor_roles, :all
88
+ end
89
+ end
90
+
91
+ namespace :deploy do
92
+ after :updating, 'supervisor:symlink'
93
+ after :publishing, 'supervisor:refresh'
94
+ end
@@ -1,3 +1,3 @@
1
1
  module Mascherano
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mascherano
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alif Rachmawadi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-22 00:00:00.000000000 Z
11
+ date: 2014-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -74,12 +74,14 @@ files:
74
74
  - lib/mascherano/foreman.rb
75
75
  - lib/mascherano/go.rb
76
76
  - lib/mascherano/passenger.rb
77
+ - lib/mascherano/supervisor.rb
77
78
  - lib/mascherano/tasks/auth_basic.cap
78
79
  - lib/mascherano/tasks/env.cap
79
80
  - lib/mascherano/tasks/figaro.cap
80
81
  - lib/mascherano/tasks/foreman.cap
81
82
  - lib/mascherano/tasks/go.cap
82
83
  - lib/mascherano/tasks/passenger.cap
84
+ - lib/mascherano/tasks/supervisor.cap
83
85
  - lib/mascherano/tasks/token.cap
84
86
  - lib/mascherano/tasks/upstart.cap
85
87
  - lib/mascherano/token.rb
@@ -111,3 +113,4 @@ signing_key:
111
113
  specification_version: 4
112
114
  summary: Capistrano 3.x recipes
113
115
  test_files: []
116
+ has_rdoc: