Setups up an http express app for an single scraper. This app allows external services to get the status of the scraper and start new scrapes
Allow node.js based scrapers to connect to a status socket so that external services can query the current status of the scraper and check if it is running or stopped.
When a scraper starts up, it registers a new service with seaport using the role scraperStatusSupplierCode. For example the NGrid Electric scraper has the supplierCode NGE so it would register with the role scraperStatusNGE
Then this module will connect to an axon rep socket on the port returned by seaport.
To query the status of a scraper, get the port of the status socket from seaport and send a status request
var inspect = require'eyespect'inspector;var config = require'nconf'var supplierCode = 'NGE'var seaConfig = configget'seaport'var seaHost = seaConfighostvar seaPort = seaConfigportvar ports = seaportconnectseaHost seaPortvar role = 'scraperStatus' + supplierCode // eg "scraperStatusNGE"var scraperStatusSockets = portsqueryrole // an array of servicesvar scraperSocketService = scraperStatusSockets0 // use the first one as an examplevar scraperSocketHost = scraperSocketServicehostvar scraperSocketPort = scraperSocketServiceportvar requestSocket = axonsocket'req'requestSocketformat'json' // all sockets speak jsonrequestSocketbindscraperSocketPort scraperSocketHost// send the messagerequestSocketsend'status'if err //should not happeninspecterr 'error getting status from NGE scraper status socket'returninspectreply 'NGE scraper status reply' // a json object with fields supplierCode & status