capistrano-ruboty 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: 9dd52957964579ff8d20506186bffc2fc6f583a2
4
+ data.tar.gz: 54df02eda7802520ebc42945dae57597d30a3eea
5
+ SHA512:
6
+ metadata.gz: d238ab5cd67ef4f2d96251df80791fd02c64f8eda9619cbe6323c21fddfc19fe109b2f66a57d7dccaa933098e439cc067336fbadbee7a11fa01d91e8642380ea
7
+ data.tar.gz: d59b8b1c2392716c84dfc2d303541374c6c5c2ad33456b89c3cd6bbce2afb13c6cc0284c9d99ba5aee0f225c1a65483be782c06674846c0a1c1d1badd2a5fb3b
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-ruboty.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Capistrano::Ruboty
2
+
3
+ Ruboty specific capistrano tasks
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano-ruboty', group: :development
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install capistrano-ruboty
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ # Capfile
25
+ require 'capistrano/ruboty'
26
+ ```
27
+
28
+ ```ruby
29
+ # config/deploy.rb
30
+ append :linked_dirs, 'tmp/pids' # corresponds to :ruboty_pid option
31
+ ```
32
+
33
+ Configurable options, shown here with defaults:
34
+
35
+ ```ruby
36
+ :ruboty_default_hooks => { true }
37
+ :ruboty_role => { :app }
38
+ :ruboty_servers => { release_roles(fetch(:ruboty_role)) }
39
+ :ruboty_env => { fetch(:ruboty_env, fetch(:stage)) }
40
+ :ruboty_command => { [:ruboty] }
41
+ :ruboty_daemon => { true }
42
+ :ruboty_dotenv => { true }
43
+ :ruboty_pid => { shared_path.join("tmp", "pids", "ruboty.pid") }
44
+ :ruboty_options => { nil }
45
+ :ruboty_stop_signal => { :TERM }
46
+ ```
47
+
48
+ ## shared `.env` file
49
+
50
+ You may need to exclude your `.env` file from your repository for security issues.
51
+
52
+ If so, you shall configure like below:
53
+
54
+ ```ruby
55
+ # config/deploy.rb
56
+ append :linked_files, '.env'
57
+ ```
58
+
59
+ , and put the `.env` file to the shared directory (its path is `<deploy_to>/shared/.env`) before deploying.
60
+
61
+ ## Development
62
+
63
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
64
+
65
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
66
+
67
+ ## Contributing
68
+
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/a2ikm/capistrano-ruboty.
70
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "capistrano/ruboty"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/ruboty/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-ruboty"
8
+ spec.version = Capistrano::Ruboty::VERSION
9
+ spec.authors = ["Masato Ikeda"]
10
+ spec.email = ["masato.ikeda@gmail.com"]
11
+
12
+ spec.summary = %q{Ruboty specific capistrano tasks}
13
+ spec.description = %q{Ruboty specific capistrano tasks}
14
+ spec.homepage = "https://github.com/a2ikm/capistrano-ruboty"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_runtime_dependency "capistrano", ">= 3.0"
24
+ spec.add_runtime_dependency "ruboty", ">= 1.3"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.13"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Ruboty
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ require "capistrano/ruboty/version"
2
+
3
+ load File.expand_path("../tasks/ruboty.rake", __FILE__)
@@ -0,0 +1,88 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ set :ruboty_default_hooks, -> { true }
4
+
5
+ set :ruboty_role, -> { :app }
6
+ set :ruboty_servers, -> { release_roles(fetch(:ruboty_role)) }
7
+ set :ruboty_env, -> { fetch(:ruboty_env, fetch(:stage)) }
8
+ set :ruboty_command, -> { [:ruboty] }
9
+ set :ruboty_daemon, -> { true }
10
+ set :ruboty_dotenv, -> { true }
11
+ set :ruboty_pid, -> { shared_path.join("tmp", "pids", "ruboty.pid") }
12
+ set :ruboty_options, -> { nil }
13
+ set :ruboty_stop_signal, -> { :TERM }
14
+
15
+ # Rbenv, Chruby, and RVM integration
16
+ set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w(ruboty))
17
+ set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w(ruboty))
18
+ set :chruby_map_bins, fetch(:chruby_map_bins).to_a.concat(%w(ruboty))
19
+
20
+ # Bundler integration
21
+ set :bundle_bins, fetch(:bundle_bins).to_a.concat(%w(ruboty))
22
+ end
23
+ end
24
+
25
+ namespace :deploy do
26
+ before :starting, :check_ruboty_hooks do
27
+ invoke "ruboty:add_default_hooks" if fetch(:ruboty_default_hooks)
28
+ end
29
+ end
30
+
31
+ namespace :ruboty do
32
+ task :start do
33
+ command_args = []
34
+ command_args += Array(fetch(:ruboty_command))
35
+ command_args += %w(--dotenv) if fetch(:ruboty_dotenv)
36
+ command_args += %w(--daemon) if fetch(:ruboty_daemon)
37
+ command_args += ["--pid", fetch(:ruboty_pid)] if fetch(:ruboty_pid)
38
+ command_args += Array(fetch(:ruboty_options)) if fetch(:ruboty_options)
39
+
40
+ on fetch(:ruboty_servers) do
41
+ within release_path do
42
+ with ruboty_env: fetch(:ruboty_env) do
43
+ execute(*command_args)
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ task :stop do
50
+ on fetch(:ruboty_servers) do
51
+ within release_path do
52
+ with ruboty_env: fetch(:ruboty_env) do
53
+ pid = existing_pid(fetch(:ruboty_pid))
54
+ if pid
55
+ execute :kill, "-s", fetch(:ruboty_stop_signal), pid
56
+ else
57
+ info "ruboty is not running."
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ def existing_pid(pid_file)
65
+ unless test("[ -f #{pid_file} ]")
66
+ debug "#{pid_file} does not exist."
67
+ return nil
68
+ end
69
+
70
+ pid = capture("cat #{pid_file}").strip
71
+
72
+ unless test("kill -0 #{pid}")
73
+ debug "process #{pid} does not exist."
74
+ return nil
75
+ end
76
+
77
+ pid
78
+ end
79
+
80
+ task :restart do
81
+ invoke "ruboty:stop"
82
+ invoke "ruboty:start"
83
+ end
84
+
85
+ task :add_default_hooks do
86
+ after "deploy:publishing", "ruboty:restart"
87
+ end
88
+ end
File without changes
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-ruboty
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masato Ikeda
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-11-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruboty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Ruboty specific capistrano tasks
70
+ email:
71
+ - masato.ikeda@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - README.md
79
+ - Rakefile
80
+ - bin/console
81
+ - bin/setup
82
+ - capistrano-ruboty.gemspec
83
+ - lib/capistrano-ruboty.rb
84
+ - lib/capistrano/ruboty.rb
85
+ - lib/capistrano/ruboty/version.rb
86
+ - lib/capistrano/tasks/ruboty.rake
87
+ homepage: https://github.com/a2ikm/capistrano-ruboty
88
+ licenses: []
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.5.2
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Ruboty specific capistrano tasks
110
+ test_files: []