-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- dashboard defaults to all watchers, added "*" to explicitly include all watchers too. - added portInUse check. - added proper exception handling for httpcheck promise
- Loading branch information
1 parent
eb027fe
commit feb862a
Showing
7 changed files
with
148 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Uses Netcat to check if a TCP port is in use | ||
*/ | ||
const NetcatClient = require('netcat/client'); | ||
|
||
module.exports = async function(watcher){ | ||
if (!watcher.host) | ||
throw `Watcher "${watcher.__name}" is missing a "host" entry.`; | ||
|
||
if (!watcher.port) | ||
throw `Watcher "${watcher.__name}" is missing a "port" entry.`; | ||
|
||
return new Promise((resolve, reject)=>{ | ||
try { | ||
const nc = new NetcatClient(); | ||
nc.addr(watcher.host).scan(watcher.port, function(ports){ | ||
if (ports[watcher.port] === 'open') | ||
return resolve('port open'); | ||
|
||
return reject('port closed'); | ||
}) | ||
}catch(ex){ | ||
reject(ex); | ||
} | ||
}); | ||
} |