https://github.com/qbit/nmon
Monitor remote files for changes. (JavaScript,NodeJS)
https://github.com/qbit/nmon
Last synced: 8 months ago
JSON representation
Monitor remote files for changes. (JavaScript,NodeJS)
- Host: GitHub
- URL: https://github.com/qbit/nmon
- Owner: qbit
- License: mit
- Created: 2012-03-25T18:08:43.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2012-12-18T14:36:26.000Z (over 13 years ago)
- Last Synced: 2025-02-19T03:18:07.221Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 133 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nmon
Fire events when the http 'last-modified' header is changed for a file.
[](http://travis-ci.org/qbit/nmon)
Currently only http and ftp are supported.
## Usage
### Install
npm install nmon
## Examples
### Monitoring a single file
```javascript
var nmon = require( 'nmon' );
var mon = new nmon();
mon.create( 'http', {
interval: 1000,
name: 'potato',
// server: 'localhost', \_________ Ftp options
// path: '/awesome', |
// port: 'ftpport', |
// user: 'ftpuser', |
// pass: 'ftppass', /
url: 'http://localhost:3000/file'
});
mon.on( 'potato', function( obj ) {
console.log( 'potato has been updated: %s', obj.date );
});
mon.monitor();
```
## Monitoring multiple files
```javascript
var nmon = require( 'nmon' );
var mon = new nmon();
var srs = [
{
interval: 1000,
name: 'file1',
url: 'http://localhost:3000/file1',
},
{
interval: 1000,
name: 'file2',
url: 'http://localhost:3000/file2',
},
/*
{
interval: 1000,
name: 'ftp1',
server: 'localhost',
path: '/awesome'
// path: '/awesome2/' if path ends with a slash, nmon will return the most recent file in that directory
}
*/
];
var i = 0, l = srs.length;
for ( ; i < l; i++ ) {
var a = srs[i], type;
if ( a.server ) {
type = 'ftp';
} else {
type = 'http';
}
mon.create( type, a );
mon.on( a.name, function( o ) {
console.log( 'TEST', o.name, o.date );
});
}
mon.monitor();
```