eatmysoul 0.1.1 → 0.1.2
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.
- data/bin/eatmysoul +2 -2
- data/lib/eatmysoul.rb +36 -30
- data/lib/eatmysoul/version.rb +1 -1
- metadata +21 -11
data/bin/eatmysoul
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
33
33
|
|
|
34
34
|
require 'daemons'
|
|
35
|
-
|
|
35
|
+
load 'lib/eatmysoul.rb'
|
|
36
36
|
|
|
37
37
|
daemon_options = {
|
|
38
38
|
:app_name => "eatmysoul",
|
|
@@ -46,6 +46,6 @@ daemon_options = {
|
|
|
46
46
|
Daemons.run_proc('eatmysoul', daemon_options) do
|
|
47
47
|
o = EatMySoul::Settings.new
|
|
48
48
|
Signal.trap("PIPE") { EatMySoul.connect_loop o }
|
|
49
|
-
EatMySoul.connect_loop(o)
|
|
49
|
+
EatMySoul::Manager.instance.connect_loop(o)
|
|
50
50
|
end
|
|
51
51
|
|
data/lib/eatmysoul.rb
CHANGED
|
@@ -32,15 +32,13 @@
|
|
|
32
32
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
33
33
|
|
|
34
34
|
require 'eventmachine'
|
|
35
|
+
require 'singleton'
|
|
35
36
|
require 'yaml'
|
|
36
37
|
require 'logger'
|
|
37
38
|
require 'digest/md5'
|
|
38
39
|
require 'trollop'
|
|
39
40
|
|
|
40
41
|
module EatMySoul
|
|
41
|
-
@@active_connection = nil
|
|
42
|
-
@@monitor = nil
|
|
43
|
-
|
|
44
42
|
class Settings
|
|
45
43
|
# edit the next line to change the default path
|
|
46
44
|
def initialize()
|
|
@@ -133,7 +131,7 @@ module EatMySoul
|
|
|
133
131
|
@o = settings
|
|
134
132
|
@status = NOT_CONNECTED
|
|
135
133
|
@last_ping = Time.now
|
|
136
|
-
|
|
134
|
+
Manager.instance.active_connection = self
|
|
137
135
|
end
|
|
138
136
|
|
|
139
137
|
def post_init
|
|
@@ -157,7 +155,7 @@ module EatMySoul
|
|
|
157
155
|
end
|
|
158
156
|
|
|
159
157
|
def unbind
|
|
160
|
-
|
|
158
|
+
Manager.instance.active_connection = nil
|
|
161
159
|
EM.add_timer(5) { EM.connect @o.server, @o.port, Netsoul, @o }
|
|
162
160
|
end
|
|
163
161
|
|
|
@@ -222,40 +220,48 @@ module EatMySoul
|
|
|
222
220
|
str.gsub!(' ', '+')
|
|
223
221
|
str
|
|
224
222
|
end
|
|
223
|
+
end # class Netsoul
|
|
225
224
|
|
|
226
|
-
end
|
|
227
225
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
226
|
+
class Manager
|
|
227
|
+
include Singleton
|
|
228
|
+
attr_accessor :active_connection, :monitor_timer
|
|
229
|
+
|
|
230
|
+
def run(o)
|
|
231
|
+
EM.run do
|
|
232
|
+
monitor_timer = EM::add_periodic_timer(1) { monitor o } unless monitor_timer
|
|
233
|
+
EM.connect o.server, o.port, Netsoul, o
|
|
234
|
+
end
|
|
232
235
|
end
|
|
233
|
-
end
|
|
234
236
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
def connect_loop(o)
|
|
238
|
+
while true do
|
|
239
|
+
sleep_time = 0
|
|
238
240
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
241
|
+
begin
|
|
242
|
+
self.run(o)
|
|
243
|
+
rescue => e
|
|
244
|
+
o.logger.fatal "Rescued from exception #{e}"
|
|
245
|
+
o.logger.debug e.backtrace.join "\n"
|
|
246
|
+
end
|
|
245
247
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
+
sleep sleep_time
|
|
249
|
+
sleep_time = sleep_time + 5 if sleep_time < 120
|
|
250
|
+
end
|
|
248
251
|
end
|
|
249
|
-
end
|
|
250
252
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
def monitor(o)
|
|
254
|
+
if active_connection
|
|
255
|
+
o.logger.debug "Checking for connection inactivity"
|
|
256
|
+
if (Time.now - active_connection.last_ping) > 650
|
|
257
|
+
o.logger.warn "Connection seems inactive, restarting ..."
|
|
258
|
+
active_connection.close_connection
|
|
259
|
+
end
|
|
256
260
|
end
|
|
257
261
|
end
|
|
258
|
-
end
|
|
259
262
|
|
|
260
|
-
end
|
|
263
|
+
end # class Manager
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
end # module EatmySoul
|
|
261
267
|
|
data/lib/eatmysoul/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,38 +1,48 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eatmysoul
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.1
|
|
5
4
|
prerelease:
|
|
5
|
+
version: 0.1.2
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Julien 'Lta' BALLET
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
|
|
16
|
-
requirement:
|
|
15
|
+
type: :runtime
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
21
|
version: '0'
|
|
22
|
-
type: :runtime
|
|
23
22
|
prerelease: false
|
|
24
|
-
version_requirements:
|
|
25
|
-
- !ruby/object:Gem::Dependency
|
|
26
|
-
name: daemons
|
|
27
|
-
requirement: &14068520 !ruby/object:Gem::Requirement
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
28
24
|
none: false
|
|
29
25
|
requirements:
|
|
30
26
|
- - ! '>='
|
|
31
27
|
- !ruby/object:Gem::Version
|
|
32
28
|
version: '0'
|
|
29
|
+
name: eventmachine
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
33
31
|
type: :runtime
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
34
38
|
prerelease: false
|
|
35
|
-
version_requirements:
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
none: false
|
|
41
|
+
requirements:
|
|
42
|
+
- - ! '>='
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '0'
|
|
45
|
+
name: daemons
|
|
36
46
|
description: A simple netsoul (epitech's internal network protocol) client, mainly
|
|
37
47
|
targeting servers
|
|
38
48
|
email:
|
|
@@ -73,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
73
83
|
version: '0'
|
|
74
84
|
requirements: []
|
|
75
85
|
rubyforge_project: eatmysoul
|
|
76
|
-
rubygems_version: 1.8.
|
|
86
|
+
rubygems_version: 1.8.24
|
|
77
87
|
signing_key:
|
|
78
88
|
specification_version: 3
|
|
79
89
|
summary: Simple chatless netsoul client
|