Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
Noah
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Noah
Commits
e0159253
Commit
e0159253
authored
Feb 27, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
starting watcher agent framework.
parent
fa4b0928
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
noah-watcher.rb
bin/noah-watcher.rb
+44
-0
No files found.
bin/noah-watcher.rb
0 → 100755
View file @
e0159253
#!/usr/bin/env ruby
$:
.
unshift
(
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
".."
,
"lib"
)))
require
'rubygems'
require
'logger'
require
'optparse'
require
'em-hiredis'
require
'thin'
require
'noah'
EventMachine
.
run
do
@logger
=
Logger
.
new
(
STDOUT
)
# Passing messages...like a boss
@channel
=
EventMachine
::
Channel
.
new
r
=
EventMachine
::
Hiredis
::
Client
.
connect
r
.
psubscribe
(
"//noah/*"
)
r
.
on
(
:pmessage
)
do
|
pattern
,
event
,
message
|
@channel
.
push
"[
#{
event
}
] [
#{
message
}
]"
@logger
.
debug
(
"Publishing [
#{
event
}
]"
)
end
sub
=
@channel
.
subscribe
{
|
msg
|
puts
msg
}
# EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 3001) do |ws|
# ws.onopen {
# sub = @channel.subscribe { |msg|
# ws.send msg
# }
#
# @channel.push "#{sub} connected and waiting...."
#
# ws.onmessage { |msg|
# @channel.push "<#{sub}>: #{msg}"
# }
#
# ws.onclose {
# @channel.unsubscribe(sub)
# }
# }
# end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment