oye 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/oye/version.rb +1 -1
- data/lib/oye.rb +25 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bf2b6f8b1f021e9b5945051d4a10a1e7d17b0972b17c9298d566ebe37405314
|
4
|
+
data.tar.gz: e8de50c9741f0bdad0c9263a2723871fce17f99328bc9e7eed2a71ef9d2f837a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1b3657913076644a229c546479eb9d8ca50a4622320a39e754dc4d5cfe209d891f77ad2a7d5afb53c7f1f34dd2f6fbb1d6e83c67a19861082afc5b89894b8c7
|
7
|
+
data.tar.gz: d5d20c18f23b559edeec125bafd29ede069e22fea9f0e117ac40452f79164d8a7a77113c7636e77f287bb9430b9ba598b2b5fd7c4dad86a9632c3559c0a189be
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -9,3 +9,5 @@ A continuous monitoring tool that does a few things:
|
|
9
9
|
[ ] use multithreaading. each thread should watch a unique repo.
|
10
10
|
[ ] run rails tests inside Oye.monitor
|
11
11
|
[ ] check for irregularities in @repos, e.g two repeated cloned repos
|
12
|
+
[ ] give warning if port is not open use port_open? method
|
13
|
+
- also you should remove the '--port' option. instead specify the port in unicorn.rb
|
data/lib/oye/version.rb
CHANGED
data/lib/oye.rb
CHANGED
@@ -3,6 +3,8 @@ $LOAD_PATH.unshift __dir__
|
|
3
3
|
require "oye/version"
|
4
4
|
require 'fileutils'
|
5
5
|
require 'yaml'
|
6
|
+
require 'socket'
|
7
|
+
require 'timeout'
|
6
8
|
|
7
9
|
module Oye
|
8
10
|
class Error < StandardError; end
|
@@ -93,8 +95,13 @@ module Oye
|
|
93
95
|
end
|
94
96
|
|
95
97
|
def monitor
|
96
|
-
|
97
|
-
|
98
|
+
%w(TERM INT).each do |signal|
|
99
|
+
trap(signal) do
|
100
|
+
stop
|
101
|
+
ProFileUtils.rm_f(oye_pidfile)
|
102
|
+
exit
|
103
|
+
end
|
104
|
+
end
|
98
105
|
|
99
106
|
@repos.keys.filter_map do |origin|
|
100
107
|
next unless File.exists?(origin)
|
@@ -263,6 +270,22 @@ module Oye
|
|
263
270
|
|
264
271
|
private
|
265
272
|
|
273
|
+
def port_open?(port)
|
274
|
+
begin
|
275
|
+
Timeout::timeout(1) do
|
276
|
+
begin
|
277
|
+
s = TCPServer.new(port)
|
278
|
+
s.close
|
279
|
+
return true
|
280
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::EADDRINUSE
|
281
|
+
return false
|
282
|
+
end
|
283
|
+
end
|
284
|
+
rescue Timeout::Error
|
285
|
+
end
|
286
|
+
return false
|
287
|
+
end
|
288
|
+
|
266
289
|
def oyedir
|
267
290
|
"#{ENV['HOME']}/.oye"
|
268
291
|
end
|