capistrano-supervisord 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-supervisord.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Yamashita Yuu
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.
@@ -0,0 +1,54 @@
1
+ # capistrano-supervisord
2
+
3
+ a capistrano recipe to deploy [supervisord](http://supervisord.org/) based services.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-supervisord'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-supervisord
18
+
19
+ ## Usage
20
+
21
+ This recipe will setup [supervisord](http://supervisord.org) during `deploy:setup` task.
22
+
23
+ To setup supervisord for your application, add following in you `config/deploy.rb`.
24
+
25
+ # in "config/deploy.rb"
26
+ require 'capistrano-supervisord'
27
+
28
+ Following options are available to manage your supervisord.
29
+
30
+ * `:supervisord_configure_cleanup_files` - files to remove on configuring supervisord.
31
+ * `:supervisord_configure_files` - list of configuration files for supervisord.
32
+ * `:supervisord_configure_path` - the root path of configuration files. use `/` by default.
33
+ * `:supervisord_configure_source_path` - the path to the templates of configuration files.
34
+ * `:supervisord_install_apt_packages` - package name of `supervisord`.
35
+ * `:supervisord_install_method` - install method. install from `:apt` by default.
36
+ * `:supervisord_service_method` - service running method. use `:sysvinit` by default.
37
+ * `:supervisord_service_name` - service name of `supervisord`. use `supervisor` by default.
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
46
+
47
+ ## Author
48
+
49
+ - YAMASHITA Yuu (https://github.com/yyuu)
50
+ - Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/)
51
+
52
+ ## License
53
+
54
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/capistrano-supervisord/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Yamashita Yuu"]
6
+ gem.email = ["yamashita@geishatokyo.com"]
7
+ gem.description = %q{a capistrano recipe to deploy supervisord based services.}
8
+ gem.summary = %q{a capistrano recipe to deploy supervisord based services.}
9
+ gem.homepage = "https://github.com/yyuu/capistrano-supervisord"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "capistrano-supervisord"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Capistrano::Supervisord::VERSION
17
+
18
+ gem.add_dependency("capistrano")
19
+ end
@@ -0,0 +1,8 @@
1
+ require "capistrano-supervisord/deploy"
2
+ require "capistrano-supervisord/version"
3
+
4
+ module Capistrano
5
+ module Supervisord
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,178 @@
1
+ require 'erb'
2
+
3
+ module Capistrano
4
+ module Supervisord
5
+ def self.extended(configuration)
6
+ configuration.load {
7
+ namespace(:deploy) {
8
+ desc("Start service.")
9
+ task(:start, :roles => :app, :except => { :no_release => true }) {
10
+ supervisord.start
11
+ }
12
+
13
+ desc("Stop service.")
14
+ task(:stop, :roles => :app, :except => { :no_release => true }) {
15
+ supervisord.stop
16
+ }
17
+
18
+ desc("Restart service.")
19
+ task(:restart, :roles => :app, :except => { :no_release => true }) {
20
+ supervisord.restart
21
+ }
22
+ }
23
+
24
+ namespace(:supervisord) {
25
+ _cset(:supervisord_configure_path, '/')
26
+ _cset(:supervisord_configure_source_path, File.join(File.dirname(__FILE__), 'templates', 'supervisord'))
27
+ _cset(:supervisord_configure_files, [])
28
+ _cset(:supervisord_configure_cleanup_files, [])
29
+
30
+ _cset(:supervisord_install_method, :apt)
31
+ _cset(:supervisord_service_method, :sysvinit)
32
+
33
+ namespace(:setup) {
34
+ desc("Setup supervisord.")
35
+ task(:default, :roles => :app, :except => { :no_release => true }) {
36
+ transaction {
37
+ install.install
38
+ configure
39
+ service.install
40
+ reload
41
+ }
42
+ }
43
+ after 'deploy:setup', 'supervisord:setup'
44
+
45
+ task(:configure, :roles => :app, :except => { :no_release => true }) {
46
+ tmp_files = []
47
+ on_rollback {
48
+ run("rm -f #{tmp_files.join(' ')}") unless tmp_files.empty?
49
+ }
50
+ supervisord_configure_files.each { |file|
51
+ src_file = File.join(supervisord_configure_source_path, file)
52
+ dst_file = File.join(supervisord_configure_path, file)
53
+ tmp_file = File.join('/tmp', File.basename(file))
54
+ if File.file?(src_file)
55
+ put(File.read(src_file), tmp_file)
56
+ elsif File.file?("#{src_file}.erb")
57
+ src_file = "#{src_file}.erb"
58
+ put(ERB.new(File.read(src_file)).result(binding), tmp_file)
59
+ else
60
+ abort("configure: no such template found: #{src_file} or #{src_file}.erb")
61
+ end
62
+ run("diff -u #{dst_file} #{tmp_file} || #{sudo} mv -f #{tmp_file} #{dst_file}; rm -f #{tmp_file}")
63
+ }
64
+ run("#{sudo} rm -rf #{supervisord_configure_cleanup_files.join(' ')}") unless supervisord_configure_cleanup_files.empty?
65
+ }
66
+ }
67
+
68
+ namespace(:install) {
69
+ task(:default, :roles => :app, :except => { :no_release => true }) {
70
+ install
71
+ }
72
+
73
+ task(:install, :roles => :app, :except => { :no_release => true }) {
74
+ __send__(supervisord_install_method).install if supervisord_install_method
75
+ }
76
+
77
+ namespace(:apt) {
78
+ _cset(:supervisord_install_apt_packages, %w(supervisor))
79
+ task(:install, :roles => :app, :except => { :no_release => true }) {
80
+ run("#{sudo} apt-get -y install #{supervisord_install_apt_packages.join(' ')}")
81
+ }
82
+ }
83
+ }
84
+
85
+ namespace(:service) {
86
+ _cset(:supervisord_service_name, 'supervisor')
87
+ task(:install, :roles => :app, :except => { :no_release => true }) {
88
+ __send__(supervisord_service_method).install if supervisord_service_method
89
+ }
90
+
91
+ namespace(:sysvinit) {
92
+ task(:install, :roles => :app, :except => { :no_release => true }) {
93
+ # nop
94
+ }
95
+
96
+ task(:start, :roles => :app, :except => { :no_release => true }) {
97
+ run("#{sudo} service #{supervisord_service_name} start")
98
+ }
99
+
100
+ task(:stop, :roles => :app, :except => { :no_release => true }) {
101
+ run("#{sudo} service #{supervisord_service_name} stop")
102
+ }
103
+
104
+ task(:status, :roles => :app, :except => { :no_release => true }) {
105
+ run("#{sudo} service #{supervisord_service_name} status")
106
+ }
107
+
108
+ task(:restart, :roles => :app, :except => { :no_release => true }) {
109
+ run("#{sudo} service #{supervisord_service_name} restart || #{sudo} service #{supervisord_service_name} start")
110
+ }
111
+
112
+ task(:reload, :roles => :app, :except => { :no_release => true }) {
113
+ run("#{sudo} service #{supervisord_service_name} force-reload || #{sudo} service #{supervisord_service_name} start")
114
+ }
115
+ }
116
+
117
+ namespace(:upstart) {
118
+ task(:install, :roles => :app, :except => { :no_release => true }) {
119
+ run("#{sudo} update-rc.d -f #{supervisord_service_name} remove; true")
120
+ }
121
+
122
+ task(:start, :roles => :app, :except => { :no_release => true }) {
123
+ run("#{sudo} service #{supervisord_service_name} start")
124
+ }
125
+
126
+ task(:stop, :roles => :app, :except => { :no_release => true }) {
127
+ run("#{sudo} service #{supervisord_service_name} stop")
128
+ }
129
+
130
+ task(:status, :roles => :app, :except => { :no_release => true }) {
131
+ run("#{sudo} service #{supervisord_service_name} status")
132
+ }
133
+
134
+ task(:restart, :roles => :app, :except => { :no_release => true }) {
135
+ run("#{sudo} service #{supervisord_service_name} restart || #{sudo} service #{supervisord_service_name} start")
136
+ }
137
+
138
+ task(:reload, :roles => :app, :except => { :no_release => true }) {
139
+ run("#{sudo} service #{supervisord_service_name} reload || #{sudo} service #{supervisord_service_name} start")
140
+ }
141
+ }
142
+ }
143
+
144
+ desc("Start supervisord daemon.")
145
+ task(:start, :roles => :app, :except => { :no_release => true }) {
146
+ service.__send__(supervisord_service_method).start if supervisord_service_method
147
+ }
148
+
149
+ desc("Stop supervisord daemon.")
150
+ task(:stop, :roles => :app, :except => { :no_release => true }) {
151
+ service.__send__(supervisord_service_method).stop if supervisord_service_method
152
+ }
153
+
154
+ desc("Restart supervisord daemon.")
155
+ task(:restart, :roles => :app, :except => { :no_release => true }) {
156
+ service.__send__(supervisord_service_method).restart if supervisord_service_method
157
+ }
158
+
159
+ desc("Reload supervisord daemon.")
160
+ task(:reload, :roles => :app, :except => { :no_release => true }) {
161
+ service.__send__(supervisord_service_method).reload if supervisord_service_method
162
+ }
163
+
164
+ desc("Show supervisord daemon status.")
165
+ task(:status, :roles => :app, :except => { :no_release => true }) {
166
+ service.__send__(supervisord_service_method).status if supervisord_service_method
167
+ }
168
+ }
169
+ }
170
+ end
171
+ end
172
+ end
173
+
174
+ if Capistrano::Configuration.instance
175
+ Capistrano::Configuration.instance.extend(Capistrano::Supervisord)
176
+ end
177
+
178
+ # vim:set ft=ruby :
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Supervisord
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-supervisord
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yamashita Yuu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-29 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: a capistrano recipe to deploy supervisord based services.
31
+ email:
32
+ - yamashita@geishatokyo.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - capistrano-supervisord.gemspec
43
+ - lib/capistrano-supervisord.rb
44
+ - lib/capistrano-supervisord/deploy.rb
45
+ - lib/capistrano-supervisord/version.rb
46
+ homepage: https://github.com/yyuu/capistrano-supervisord
47
+ licenses: []
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.23
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: a capistrano recipe to deploy supervisord based services.
70
+ test_files: []
71
+ has_rdoc: