guard-rpush 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/guard-rpush.gemspec +25 -0
- data/lib/guard/rpush.rb +134 -0
- data/lib/guard/rpush/version.rb +5 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4b1678772a6bc5a7d25094940304d2a925498403
|
4
|
+
data.tar.gz: 31dd61fc1aca3ded2c9968416032c8dbd11ca931
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3ce7441fc7c30969212ee26c6a1fa8106a9f066727f92bf4c04a1aa70a6c967154aa2e5766b89cc32ae2028214935644c07412d918ec0af90c832241424fb5b3
|
7
|
+
data.tar.gz: 59ad0842cd406a449f1bc08eba654ad86edeb38bc3f1b5ea74879855781278cf493558875dd7ef6dbfe4f59a58ca6cf6b7183b214dbb5f270174663aba53f571
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
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
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 akhildave
|
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,35 @@
|
|
1
|
+
# Guard::Rpush
|
2
|
+
|
3
|
+
Automatically manages rpush daemon
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'guard-rpush'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install guard-rpush
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Add this line to your application's Gaurdfile:
|
22
|
+
|
23
|
+
guard 'guard-rpush'
|
24
|
+
|
25
|
+
Or with pidfile directory & environment as below:
|
26
|
+
|
27
|
+
guard 'rpush', :pidfile => 'tmp/pids/rpush.pid', :environment => 'production'
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it ( https://github.com/akhildave/guard-rpush/fork )
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/guard-rpush.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'guard/rpush/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "guard-rpush"
|
8
|
+
spec.version = Guard::RpushVersion::VERSION
|
9
|
+
spec.authors = ["akhildave"]
|
10
|
+
spec.email = ["akhiltheway@gmail.com"]
|
11
|
+
spec.summary = %q{Guard plugin for rpush.}
|
12
|
+
spec.description = %q{Guard::Rpush automatically starts and restarts your local rpush daemon.}
|
13
|
+
spec.homepage = "https://github.com/akhildave/guard-rpush"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency 'guard', '~> 2.6'
|
24
|
+
spec.add_dependency 'guard-compat', '~> 1.1'
|
25
|
+
end
|
data/lib/guard/rpush.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
require "guard/rpush/version"
|
2
|
+
require 'guard/compat/plugin'
|
3
|
+
module Guard
|
4
|
+
class Rpush < Plugin
|
5
|
+
DEFAULT_SIGNAL = :TERM
|
6
|
+
|
7
|
+
def start
|
8
|
+
@rpush_started = false
|
9
|
+
begin
|
10
|
+
check_init_pidfile_directory
|
11
|
+
UI.info "Starting Rpush daemon.."
|
12
|
+
sid = spawn({},cmd)
|
13
|
+
Process.wait(sid)
|
14
|
+
UI.info "Rpush is running with PID #{pid}"
|
15
|
+
@rpush_started = $?.success?
|
16
|
+
rescue ::Exception => err
|
17
|
+
UI.error "Unable to start Rpush. Errors: #{err}"
|
18
|
+
end
|
19
|
+
@rpush_started
|
20
|
+
end
|
21
|
+
|
22
|
+
def stop
|
23
|
+
if @rpush_started
|
24
|
+
shutdown_rpush
|
25
|
+
true
|
26
|
+
else
|
27
|
+
UI.info "Rpush was not started. Skipping stop process.."
|
28
|
+
true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def reload
|
33
|
+
UI.info "Reloading Rpush..."
|
34
|
+
stop
|
35
|
+
start
|
36
|
+
UI.info "Rpush restarted successfully."
|
37
|
+
end
|
38
|
+
|
39
|
+
def run_all
|
40
|
+
true
|
41
|
+
end
|
42
|
+
|
43
|
+
def run_on_change(paths)
|
44
|
+
reload if reload_on_change?
|
45
|
+
end
|
46
|
+
|
47
|
+
def shutdown_rpush
|
48
|
+
return UI.info "No instance of Rpush to stop." unless pid
|
49
|
+
return UI.info "Rpush (#{pid}) was already stopped." unless process_running?
|
50
|
+
UI.info "Sending TERM signal to Rpush (#{pid})..."
|
51
|
+
Process.kill("TERM", pid)
|
52
|
+
|
53
|
+
return if shutdown_retries == 0
|
54
|
+
shutdown_retries.times do
|
55
|
+
return UI.info "Rpush stopped." unless process_running?
|
56
|
+
UI.info "Rpush is still shutting down. Retrying in #{ shutdown_wait } second(s)..."
|
57
|
+
sleep shutdown_wait
|
58
|
+
end
|
59
|
+
UI.error "Rpush didn't shut down after #{ shutdown_retries * shutdown_wait } second(s)."
|
60
|
+
end
|
61
|
+
|
62
|
+
def pidfile_path
|
63
|
+
options.fetch(:pidfile) {
|
64
|
+
File.expand_path('/tmp/rpush.pid', File.dirname(__FILE__))
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
def check_init_pidfile_directory
|
69
|
+
pidfile_dir = File.dirname(pidfile_path)
|
70
|
+
unless Dir.exist? pidfile_dir
|
71
|
+
UI.info "Creating directory #{pidfile_dir} for pidfile"
|
72
|
+
FileUtils.mkdir_p pidfile_dir
|
73
|
+
end
|
74
|
+
|
75
|
+
unless File.writable? pidfile_dir
|
76
|
+
raise "No write access to pidfile directory #{pidfile_dir}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def pid
|
81
|
+
count = 0
|
82
|
+
loop do
|
83
|
+
if count > 5
|
84
|
+
raise "pidfile was never written to #{pidfile_path}"
|
85
|
+
end
|
86
|
+
|
87
|
+
break if File.exists? pidfile_path
|
88
|
+
UI.info "Waiting for pidfile to appear at #{pidfile_path}..."
|
89
|
+
count += 1
|
90
|
+
sleep 1
|
91
|
+
end
|
92
|
+
File.read(pidfile_path).to_i
|
93
|
+
end
|
94
|
+
|
95
|
+
def cmd
|
96
|
+
command = ['bundle exec rpush start']
|
97
|
+
command << "-e #{@options[:environment]}" if @options[:environment]
|
98
|
+
command.join(' ')
|
99
|
+
end
|
100
|
+
|
101
|
+
def logfile
|
102
|
+
options.fetch(:logfile) {
|
103
|
+
if capture_logging? then "log/rpush.log" else 'stdout' end
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
def shutdown_retries
|
108
|
+
options.fetch(:shutdown_retries) { 0 }
|
109
|
+
end
|
110
|
+
|
111
|
+
def shutdown_wait
|
112
|
+
options.fetch(:shutdown_wait) { 0 }
|
113
|
+
end
|
114
|
+
|
115
|
+
def reload_on_change?
|
116
|
+
options.fetch(:reload_on_change) { false }
|
117
|
+
end
|
118
|
+
|
119
|
+
def process_running?
|
120
|
+
begin
|
121
|
+
Process.getpgid pid
|
122
|
+
true
|
123
|
+
rescue Errno::ESRCH
|
124
|
+
false
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def capture_logging?
|
129
|
+
options.fetch(:capture_logging) { false }
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-rpush
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- akhildave
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.6'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-compat
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.1'
|
69
|
+
description: Guard::Rpush automatically starts and restarts your local rpush daemon.
|
70
|
+
email:
|
71
|
+
- akhiltheway@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- guard-rpush.gemspec
|
82
|
+
- lib/guard/rpush.rb
|
83
|
+
- lib/guard/rpush/version.rb
|
84
|
+
homepage: https://github.com/akhildave/guard-rpush
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.2.2
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Guard plugin for rpush.
|
108
|
+
test_files: []
|
109
|
+
has_rdoc:
|