mina-extras 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/mina-extras/auto-repository.rb +1 -0
- data/lib/mina-extras/git.rb +1 -0
- data/lib/mina-extras/jruby-patch.rb +100 -0
- data/lib/mina-extras/puma.rb +38 -0
- data/lib/mina-extras/rvm.rb +8 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d25ae529d9db05f253bd86b426f12ce080a7094a
|
4
|
+
data.tar.gz: d9d47dd78b70b7ff08a12dd11dbe09f0de0376af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c441081e9f5d83d3feaa3ce01a676a60cf509f2de05a0730e42a665364a0eae31fbbfcdb637f73aa065214e220a66bf140f60bf15159bd21fc412870d9be3f10
|
7
|
+
data.tar.gz: c5dde9251553e8de290226001745ce531266cbd8db7d537bd64a0f11fb7be0e09764bcabb8fe42ad64bb40a4f5aa4b907c65fcf6be62316c7712b278ae38a6fa
|
@@ -0,0 +1 @@
|
|
1
|
+
set :repository, %x[git config --get remote.origin.url].strip
|
@@ -0,0 +1 @@
|
|
1
|
+
set :current_git_branch, %x[git rev-parse --abbrev-ref HEAD].strip
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# # Helpers: Exec helpers
|
2
|
+
# Provides `pretty_system` which Mina uses to parse SSH output, and delegate to
|
3
|
+
# the appropriate Output helper.
|
4
|
+
|
5
|
+
module Mina
|
6
|
+
module ExecHelpers
|
7
|
+
|
8
|
+
# ### pretty_system
|
9
|
+
# __Internal:__ A pretty version of the default `#system` commands, but
|
10
|
+
# indents and puts color.
|
11
|
+
#
|
12
|
+
# Returns the exit code in integer form.
|
13
|
+
#
|
14
|
+
def pretty_system(code)
|
15
|
+
require 'shellwords'
|
16
|
+
cmds = Shellwords.shellsplit(code)
|
17
|
+
coathooks = 0
|
18
|
+
|
19
|
+
status =
|
20
|
+
Tools.popen4(*cmds) do |pid, i, o, e|
|
21
|
+
# Handle `^C`.
|
22
|
+
trap("INT") { Sys.handle_sigint(coathooks += 1, pid, self) }
|
23
|
+
|
24
|
+
# __In the background,__ make stdin passthru, and stream stderr.
|
25
|
+
th_err = Sys.stream_stderr!(e) { |str| print_stderr str }
|
26
|
+
th_in = Sys.stream_stdin! { |chr| i.putc chr }
|
27
|
+
|
28
|
+
# __In the foreground,__ stream stdout to the output helper.
|
29
|
+
Sys.stream_stdout(o) { |ch| print_char ch }
|
30
|
+
|
31
|
+
th_err.join
|
32
|
+
th_in.terminate
|
33
|
+
end
|
34
|
+
|
35
|
+
status.exitstatus
|
36
|
+
end
|
37
|
+
|
38
|
+
# ## Private methods
|
39
|
+
# Delegate functions, mostly.
|
40
|
+
|
41
|
+
module Sys
|
42
|
+
|
43
|
+
extend self
|
44
|
+
|
45
|
+
# ### Sys.handle_sigint!
|
46
|
+
# Called when a `^C` is pressed. The param `count` is how many times it's
|
47
|
+
# been pressed since. Returns nothing.
|
48
|
+
|
49
|
+
def handle_sigint(count, pid, this)
|
50
|
+
puts ""
|
51
|
+
if count > 1
|
52
|
+
this.print_status "Mina: SIGINT received again. Force quitting..."
|
53
|
+
Process.kill "KILL", pid
|
54
|
+
else
|
55
|
+
this.print_status "Mina: SIGINT received."
|
56
|
+
Process.kill "TERM", pid
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# ### Sys.stream_stderr!
|
61
|
+
# __Internal:__ Read from stderr stream `err` *[0]*, supress expected
|
62
|
+
# errors *[1]*, and yield. Returns the PID.
|
63
|
+
|
64
|
+
def stream_stderr!(err, &blk)
|
65
|
+
Thread.new do
|
66
|
+
while str = err.gets #[0]
|
67
|
+
next if str.include? "bash: no job control in this shell" #[1]
|
68
|
+
next if str.include? "stdin is not a terminal"
|
69
|
+
|
70
|
+
yield str.strip #[2]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# ### Sys.stream_stdin!
|
76
|
+
# __Internal:__ Read from the real stdin stream and pass it onto the given
|
77
|
+
# stdin stream `i`. Returns the PID.
|
78
|
+
|
79
|
+
def stream_stdin!(&blk)
|
80
|
+
Thread.new do
|
81
|
+
while (char = STDIN.getbyte rescue nil)
|
82
|
+
yield char if char
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# ### Sys.stream_stdout
|
88
|
+
# __Internal:__ Read from given stdout stream `o` and delegate it to the
|
89
|
+
# output helper.
|
90
|
+
|
91
|
+
def stream_stdout(o, &blk)
|
92
|
+
while str = o.getc
|
93
|
+
yield str
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
namespace :puma do
|
2
|
+
task :config do
|
3
|
+
cmd_prefix = "cd #{deploy_to}/#{current_path} ; "
|
4
|
+
cmd_prefix += "RAILS_ENV=#{rails_env!} NEW_RELIC_DISPATCHER=puma bundle exec"
|
5
|
+
set :puma_start_cmd, "#{cmd_prefix} puma -C #{File.join(deploy_to,current_path,'config','puma.rb')}"
|
6
|
+
set :puma_stop_cmd, "#{cmd_prefix} pumactl -S #{deploy_to}/#{shared_path}/sockets/puma.state stop"
|
7
|
+
set :puma_restart_cmd, "#{cmd_prefix} pumactl -S #{deploy_to}/#{shared_path}/sockets/puma.state phased-restart"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Start puma'
|
11
|
+
task :start => [:config, :environment] do
|
12
|
+
queue %{
|
13
|
+
echo "-----> Starting puma"
|
14
|
+
#{echo_cmd puma_start_cmd}
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Stop puma'
|
19
|
+
task :stop => [:config, :environment] do
|
20
|
+
queue %{
|
21
|
+
echo "-----> Stopping puma"
|
22
|
+
#{echo_cmd puma_stop_cmd}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Restart puma'
|
27
|
+
task :restart => [:config, :environment] do
|
28
|
+
queue %{
|
29
|
+
if [ ! -f "#{deploy_to}/#{shared_path}/sockets/puma.state" ]; then
|
30
|
+
echo "-----> Starting puma"
|
31
|
+
#{echo_cmd puma_start_cmd}
|
32
|
+
else
|
33
|
+
echo "-----> Restarting puma"
|
34
|
+
#{echo_cmd puma_restart_cmd}
|
35
|
+
fi
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mina-extras
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Berdajs
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mina
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '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'
|
27
|
+
description: Provides extra Mina deploy tasks for Puma, RVM, Faye.
|
28
|
+
email: mrbrdo@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/mina-extras/auto-repository.rb
|
34
|
+
- lib/mina-extras/git.rb
|
35
|
+
- lib/mina-extras/jruby-patch.rb
|
36
|
+
- lib/mina-extras/puma.rb
|
37
|
+
- lib/mina-extras/rvm.rb
|
38
|
+
homepage: https://github.com/mrbrdo/mina-extras
|
39
|
+
licenses:
|
40
|
+
- MIT
|
41
|
+
metadata: {}
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 2.0.4
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
61
|
+
summary: extra mina deploy tasks
|
62
|
+
test_files: []
|