Created
May 2, 2014 11:58
-
-
Save TerryMooreII/da7fda8c72471b51537e to your computer and use it in GitHub Desktop.
Sending the initial heartbeat. - Cardinal Solutions ALF blog post
This file contains hidden or 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
| function heartbeatInit(properties) { | |
| console.log('HeartbeatService.init.heartbeatInit: Sending initial heartbeat to ALF server @ ' + properties.alfServer + ':' + properties.alfServerPort + properties.PATH_TO_ALF_HEARTBEAT_SERVICE + ' for host "' + hostName + '"...'); | |
| // Setup the data that's going to be sent to the ALF server on agent init | |
| var initData = { | |
| agentName: properties.agentName, | |
| hostName: hostName, | |
| port: properties.port, | |
| services: properties.services | |
| }; | |
| // Configure the HTTP Request options | |
| var options = { | |
| host: properties.alfServer, | |
| port: properties.alfServerPort, | |
| path: properties.PATH_TO_ALF_HEARTBEAT_SERVICE, | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| } | |
| }; | |
| // Setup the HTTP request /w the options above, and register onSuccess/onError handlers | |
| var request = http.request(options, function(response) { | |
| console.log('HeartbeatService.init.heartbeatInit: Successfully sent heartbeat.'); | |
| }); | |
| request.on('error', function(e) { | |
| console.log('HeartbeatService.init.heartbeatInit: Unable to establish a connection to the ALF server ' + properties.alfServer + '. Error Message: ' + e.message); | |
| }); | |
| // Send the initData from above on the HTTP request | |
| request.write(JSON.stringify(initData)); | |
| request.end(); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment