glados
v1.0.1
Published
Monitor remote resource for changes
Downloads
78
Maintainers
Readme
glados
Monitor remote resource for changes
- Use the cli wrapper to send an email notification or POST to a url when the resource has changed
- Diffs are calculated using kpdecker's diff
- Will not start polling until client binds to
'change'
- Use the CLI Wrapper to take action on
'change'
- POST to an endpoint, or
- send email notification (supports Gmail and SES)
App
var glados = require('glados')
var watcher = glados('http://example.com/sensitive_data.html', 1000*60)
.on('change',function(diff){
// do something with diff
})
.on('error',function(err){
// we have some problem connecting with resource
})
CLI Wrapper
See api notes below for opts
node ./bin/cli.js http://example.com/sensitive_data.html -n60000 \
-p http://myapi.example.com/notify_change \
-m [email protected]
Forever Wrapper
Make sure this thing never goes down. Wraps cli.js with sturdiness. Kill the process, stop the forever, reboot the instance. Baby will still be kickin. Most recently polled data is saved to tmp file in case process dies and reboots.
./bin/forever.sh http://example.com/sensitive_data.html -n60000 \
-p http://myapi.example.com/notify_change \
-m [email protected]
Kill Forever
Shut down what you started with forever.sh
./bin/kill_forever.sh http://example.com/sensitive_data.html
# or kill processes that contain -s (softmatch):
./bin/kill_forever.sh -s sensitive_data.html
App Api
glados( url [, pollInterval] )
returns a watcher
that will monitor changes of url
url
string - remote resource to watch
pollInterval
int - interval in ms to check resource for changes. defaults to 1 minute
watcher.stop()
Stop watching. No further events will be fired after this is called.
watcher.on('change', function(diff, data){})
Fired when a change has been detected in remote resource
diff
Array - an array of data comprising added, removed, and unchanged chunks
data
Buffer - the new data, unadulterated
watcher.on('connection', function(data){})
Fired on response from initial poll
data
Buffer - the response data
watcher.on('poll', function(){})
Fired immediately prior to each poll. The first 'poll'
event occurs before 'connection'
watcher.on('error', function(err){})
Catch errors in the stream
CLI Api
Arguments
Applies to both cli.js
and forever.sh
[target]
- url of resource to watch
-n
or--interval
- pollInterval
- optional, defaults to 1 minute
-p
or--post
- endpoint to post
diff
on change event - optional
- supports multiple
- endpoint to post
-m
or--email
- email address to send
diff
on change event - optional
- supports multiple
- email address to send
Copy config.json
to config.local.json
and add credentials
Gmail
Set mailTransport
to 'gmail'
Use an application password (not your personal account password)
SES
Set mailTransport
to 'ses'
Set your AWS secret and key, along with an approved From address
To Do
- Using the softmatch option (
kill_forever.sh -s "substring"
) currently kills only the first match found, but deletes all matching saved data- Update script to kill all matches as advertised in readme
- Add screenshot of pretty email to readme