capistrano-runit-danthes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5a817065cd60b3a887c3b9cb8b25b04e64261d8d
4
+ data.tar.gz: f81f4e02e0dae33d27191bda274db38ff5b07287
5
+ SHA512:
6
+ metadata.gz: c9153036e433b511b0b86545c02094bb8ee68ea3d8cf7e412a7c1dd1224496d8fee17127da26bf388270e48881fb5d942bbe2e516aba4b8a4172cf40a21a2951
7
+ data.tar.gz: d5649cc9bef79b6aca5cab16d75970469a7617d7b604eb8476186e641b1b8d8b378bc24dd791f30a7dd1a3d943e03832f9f9c8675ee420eadfc39d9213723893
data/.gitignore ADDED
@@ -0,0 +1,23 @@
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
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-runit-danthes.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Alexander Simonov
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,56 @@
1
+ # capistrano-runit-danthes
2
+
3
+ Capistrano3 tasks for manage danthes through puma via runit supervisor.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-runit-danthes'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-runit-danthes
18
+
19
+ ## Usage
20
+
21
+ Add this line in `Capfile`:
22
+ ```
23
+ require 'capistrano/runit/danthes'
24
+ ```
25
+
26
+ ## Tasks
27
+
28
+ * `runit:danthes:setup` -- setup danthes runit service.
29
+ * `runit:danthes:enable` -- enable and autostart service.
30
+ * `runit:danthes:disable` -- stop and disable service.
31
+ * `runit:danthes:start` -- start service.
32
+ * `runit:danthes:stop` -- stop service.
33
+ * `runit:danthes:restart` -- restart service.
34
+
35
+ ## Variables
36
+
37
+ * `runit_danthes_role` -- what host roles uses runit to run danthes. Default value: `:app`
38
+ * `runit_danthes_default_hooks` -- run default hooks for runit danthes or not. Default value: `true`.
39
+ * `runit_danthes_threads_min` -- minimal threads to use. Default value: 0.
40
+ * `runit_danthes_threads_max` -- maximal threads to use. Default value: 16.
41
+ * `runit_danthes_bind` -- bind URI. Examples: tcp://127.0.0.1:8080, unix:///tmp/danthes.sock. Default value: `tcp://127.0.0.1:9292`.
42
+ * `runit_danthes_rackup` -- Path to application's rackup file. Default value: `File.join(current_path, 'danthes.ru')`
43
+ * `runit_danthes_state` -- Path to danthes's state file. Default value: `File.join(shared_path, 'tmp', 'pids', 'danthes.state')`
44
+ * `runit_danthes_pid` -- Path to pid file. Default value: `File.join(shared_path, 'tmp', 'pids', 'danthes.pid')`
45
+ * `runit_danthes_bind` -- Puma's bind string. Default value: `File.join('unix://', shared_path, 'tmp', 'sockets', 'danthes.sock')`
46
+ * `runit_danthes_conf` -- Path to danthes's config file. Default value: `File.join(shared_path, 'danthes.rb')`
47
+ * `runit_danthes_access_log` -- Path to danthes's access log. Default value: `File.join(shared_path, 'log', 'danthes_access.log')`
48
+ * `runit_danthes_error_log` -- Path to danthes's error log. Default value: `File.join(shared_path, 'log', 'danthes_access.log')`
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it ( https://github.com/capistrano-runit/capistrano-runit-danthes/fork )
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,19 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "capistrano-runit-danthes"
5
+ spec.version = '0.1.0'
6
+ spec.authors = ["Alexander Simonov"]
7
+ spec.email = ["alex@simonov.me"]
8
+ spec.summary = %q{Capistrano3 tasks for manage danthes through puma via runit supervisor.}
9
+ spec.description = %q{Capistrano3 tasks for manage danthes through puma via runit supervisor.}
10
+ spec.homepage = 'http://capistrano-runit.github.io'
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files -z`.split("\x0")
14
+ spec.require_paths = ["lib"]
15
+
16
+ spec.add_runtime_dependency 'capistrano-runit-core', '~> 0.1.0'
17
+ spec.add_development_dependency "bundler", "~> 1.6"
18
+ spec.add_development_dependency "rake"
19
+ end
@@ -0,0 +1,2 @@
1
+ require 'capistrano/runit'
2
+ load File.expand_path('../../tasks/danthes.rake', __FILE__)
@@ -0,0 +1,126 @@
1
+ require 'erb'
2
+ include ::Capistrano::Runit
3
+
4
+ namespace :load do
5
+ task :defaults do
6
+ set :runit_danthes_role, -> { :app }
7
+ set :runit_danthes_default_hooks, -> { true }
8
+ set :runit_danthes_run_template, File.expand_path('../../templates/run.erb', __FILE__)
9
+ set :runit_danthes_threads_min, 0
10
+ set :runit_danthes_threads_max, 16
11
+ set :runit_danthes_rackup, -> { File.join(current_path, 'danthes.ru') }
12
+ set :runit_danthes_state, -> { File.join(shared_path, 'tmp', 'pids', 'danthes.state') }
13
+ set :runit_danthes_pid, -> { File.join(shared_path, 'tmp', 'pids', 'danthes.pid') }
14
+ set :runit_danthes_bind, -> { 'tcp://127.0.0.1:9292' }
15
+ set :runit_danthes_conf, -> { File.join(shared_path, 'danthes.rb') }
16
+ set :runit_danthes_conf_in_repo, -> { false }
17
+ set :runit_danthes_access_log, -> { File.join(shared_path, 'log', 'danthes_access.log') }
18
+ set :runit_danthes_error_log, -> { File.join(shared_path, 'log', 'danthes_error.log') }
19
+ end
20
+ end
21
+
22
+ namespace :deploy do
23
+ before :starting, :runit_check_danthes_hooks do
24
+ invoke 'runit:danthes:add_default_hooks' if fetch(:runit_danthes_default_hooks)
25
+ end
26
+ end
27
+
28
+ namespace :runit do
29
+ namespace :danthes do
30
+
31
+ def path_to_danthes_service_dir
32
+ enabled_service_dir_for('danthes')
33
+ end
34
+
35
+ def template_danthes(from, to)
36
+ [
37
+ File.expand_path("../#{from}.rb.erb", __FILE__),
38
+ File.expand_path("../#{from}.erb", __FILE__)
39
+ ].each do |path|
40
+ if File.file?(path)
41
+ template = ERB.new(File.read(path))
42
+ stream = StringIO.new(template.result(binding))
43
+ upload! stream, "#{to}"
44
+ break
45
+ end
46
+ end
47
+ end
48
+
49
+ def collect_danthes_run_command
50
+ array = []
51
+ array << env_variables
52
+ array << "exec #{SSHKit.config.command_map[:bundle]} exec puma"
53
+ danthes_conf_path = if fetch(:runit_danthes_conf_in_repo)
54
+ "#{release_path}/config/danthes.rb"
55
+ else
56
+ fetch(:runit_danthes_conf)
57
+ end
58
+ array << "-C #{danthes_conf_path}"
59
+ array.compact.join(' ')
60
+ end
61
+
62
+ def create_danthes_default_conf
63
+ warn 'danthes.rb NOT FOUND!'
64
+ path = File.expand_path('../../templates/danthes.rb.erb', __FILE__)
65
+ if File.file?(path)
66
+ template = ERB.new(File.read(path))
67
+ stream = StringIO.new(template.result(binding))
68
+ upload! stream, "#{fetch(:runit_danthes_conf)}"
69
+ info 'danthes.rb generated'
70
+ end
71
+ end
72
+
73
+ task :add_default_hooks do
74
+ after 'deploy:check', 'runit:danthes:check'
75
+ end
76
+
77
+ task :check do
78
+ check_service('danthes')
79
+ on roles fetch(:runit_danthes_role) do
80
+ if test "[ -d #{path_to_danthes_service_dir} ]"
81
+ # Create danthes.rb for new deployments if not in repo
82
+ if !fetch(:runit_danthes_conf_in_repo) && !test("[ -f #{fetch(:runit_danthes_conf)} ]")
83
+ create_danthes_default_conf
84
+ end
85
+ else
86
+ error "Danthes runit service isn't enabled."
87
+ end
88
+ end
89
+ end
90
+
91
+ desc 'Setup danthes runit service'
92
+ task :setup do
93
+ # requirements
94
+ if fetch(:runit_danthes_bind).nil?
95
+ $stderr.puts "You should set 'runit_danthes_bind' variable."
96
+ exit 1
97
+ end
98
+ setup_service('danthes', collect_danthes_run_command)
99
+ end
100
+
101
+ desc 'Enable danthes runit service'
102
+ task :enable do
103
+ enable_service('danthes')
104
+ end
105
+
106
+ desc 'Disable danthes runit service'
107
+ task :disable do
108
+ disable_service('danthes')
109
+ end
110
+
111
+ desc 'Start danthes runit service'
112
+ task :start do
113
+ start_service('danthes')
114
+ end
115
+
116
+ desc 'Stop danthes runit service'
117
+ task :stop do
118
+ stop_service('danthes')
119
+ end
120
+
121
+ desc 'Restart danthes runit service'
122
+ task :restart do
123
+ restart_service('danthes')
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,17 @@
1
+ directory '<%= current_path %>'
2
+ environment 'production'
3
+ daemonize false
4
+ quiet
5
+ rackup '<%= fetch(:runit_danthes_rackup) %>'
6
+ pidfile '<%= fetch(:runit_danthes_pid) %>'
7
+ state_path '<%= fetch(:runit_danthes_state) %>'
8
+ stdout_redirect '<%= fetch(:runit_danthes_access_log) %>', '<%= fetch(:runit_danthes_error_log) %>', true
9
+
10
+ workers 1
11
+ threads <%= fetch(:runit_danthes_threads_min, 0) %>, <%= fetch(:runit_danthes_threads_max, 16) %>
12
+ bind "<%= fetch(:runit_danthes_bind) %>"
13
+
14
+ on_restart do
15
+ puts 'Refreshing Gemfile'
16
+ ENV["BUNDLE_GEMFILE"] = "<%= fetch(:bundle_gemfile, "#{current_path}/Gemfile") %>"
17
+ end
File without changes
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-runit-danthes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Simonov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano-runit-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Capistrano3 tasks for manage danthes through puma via runit supervisor.
56
+ email:
57
+ - alex@simonov.me
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - capistrano-runit-danthes.gemspec
68
+ - lib/capistrano-runit-danthes.rb
69
+ - lib/capistrano/runit/danthes.rb
70
+ - lib/capistrano/tasks/danthes.rake
71
+ - lib/capistrano/templates/danthes.rb.erb
72
+ homepage: http://capistrano-runit.github.io
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Capistrano3 tasks for manage danthes through puma via runit supervisor.
96
+ test_files: []