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
e2a3add6
Commit
e2a3add6
authored
Aug 05, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bandaid for watcher script until it's broken out. Not proud about it
parent
2132b59b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
15 deletions
+51
-15
noah-watcher.rb
bin/noah-watcher.rb
+50
-15
noah.gemspec
noah.gemspec
+1
-0
No files found.
bin/noah-watcher.rb
View file @
e2a3add6
#!/usr/bin/env ruby
$:
.
unshift
(
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
".."
,
"lib"
)))
CONNERRHELP
=
<<
EOC
---------------------------------------------------------------------------
Apparently we could not connect to the redis instance.
By default the watcher will attempt to connect to "redis://localhost:6379/0"
If your redis instance is listening elsewhere, please start like so:
REDIS_URL="redis://hostname:port/dbnum" noah-watcher.rb
This will be rectified in a future release. Sorry about that.
----------------------------------------------------------------------------
EOC
HELP
=
<<-
EOH
---------------------------------------------------------------------------------------
Unfortunately, the agent script has some difficult requirements right now.
Please see https://github.com/lusis/Noah/Watcher-Agent for details.
Please rerun with the '--depinstall' option to have them installed for you and try again
---------------------------------------------------------------------------------------
EOH
require
'rubygems'
require
'slop'
require
'logger'
require
'json'
opts
=
Slop
.
parse
do
banner
"Usage: noah-watcher.rb [options]"
on
'--depinstall'
,
"Installs additional dependencies"
do
puts
"Installing dependencies"
puts
"em-hiredis..."
`gem install em-hiredis`
puts
"em-http-request prerelease..."
`gem install em-http-request --pre`
puts
"cookiejar...."
`gem install cookiejar`
exit
end
on
:h
,
:help
,
'Print help'
,
:tail
=>
true
do
puts
help
exit
end
end
begin
require
'rubygems'
require
'logger'
require
'optparse'
require
'em-hiredis'
require
'eventmachine'
require
'em-http-request'
require
'noah'
require
'noah/agent'
require
'json'
require
'cookiejar'
rescue
LoadError
=>
e
puts
e
.
message
puts
HELP
exit
end
begin
require
'noah'
require
'noah/agent'
rescue
Errno
::
ECONNREFUSED
puts
CONNERRHELP
exit
end
Noah
::
Log
.
logger
=
Logger
.
new
(
STDOUT
)
LOGGER
=
Noah
::
Log
.
logger
LOGGER
.
progname
=
__FILE__
...
...
@@ -32,21 +74,14 @@ EventMachine.run do
noah
=
Noah
::
Agent
.
new
noah
.
errback
{
|
x
|
LOGGER
.
error
(
"Errback:
#{
x
}
"
)}
noah
.
callback
{
|
y
|
LOGGER
.
info
(
"Callback:
#{
y
}
"
)}
# Passing messages...like a boss
#master_channel = EventMachine::Channel.new
r
=
EventMachine
::
Hiredis
::
Client
.
connect
r
=
EventMachine
::
Hiredis
.
connect
(
ENV
[
"REDIS_URL"
])
r
.
errback
{
|
x
|
LOGGER
.
error
(
"Unable to connect to redis:
#{
x
}
"
)}
LOGGER
.
info
(
"Attaching to Redis Pubsub"
)
r
.
psubscribe
(
"*"
)
r
.
on
(
:pmessage
)
do
|
pattern
,
event
,
message
|
noah
.
reread_watchers
if
event
=~
/^\/\/noah\/watchers\/.*/
noah
.
broker
(
"
#{
event
}
|
#{
message
}
"
)
unless
noah
.
watchers
==
0
#master_channel.push "#{event}|#{message}"
end
#sub = master_channel.subscribe {|msg|
# We short circuit if we have no watchers
# noah.broker(msg) unless noah.watchers == 0
#}
end
noah.gemspec
View file @
e2a3add6
...
...
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
s
.
add_dependency
(
"
haml
"
,
[
"= 3.0.25"
])
s
.
add_dependency
(
"
vegas
"
,
[
"= 0.1.8"
])
s
.
add_dependency
(
"
guid
"
,
[
"= 0.1.1"
])
s
.
add_dependency
(
"
slop
"
,
[
"= 2.1.0"
])
if
RUBY_PLATFORM
=~
/java/
...
...
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