var express = require('express'),
	router = express.Router(),
	net = require('net'),
	fs = require('fs'),
	socketPath = '/tmp/haproxy';


/* GET home page. */
router.post('/', function(req, res) {
	// console.log(req.body);
	// you can get commit information from request body

	var client = net.createConnection(socketPath);

	client.on('connect', function () {
		console.log('check connection');

		var writeResult = client.write('show health');

		console.log(writeResult);

		client.on('data', function (data) {
			console.log('read here');
			console.log('DATA: '+data);
		});
	});

	

	/*
	fs.stat(socketPath, function (err) {
		if (!err) {
			fs.unlinkSync(socketPath);
			return;
		}

		var unixServer = net.createServer(function (sock) {
			sock.write('show health');

			sock.on('data', function (data) {
				winston.debug('DATA: '+data);
				sock.destroy();
			});

		}).listen(socketPath);
	});
	*/

	res.send('complete');
});

module.exports = router;

@@ -441,17 +441,16 @@
 alth');%0A
-%0A
 %09%09consol
@@ -469,18 +469,22 @@
 esult);%0A
-%0A
 %09
+%7D);%0A%0A
 %09client.
@@ -514,17 +514,16 @@
 ta) %7B%0A%09%09
-%09
 console.
@@ -540,17 +540,16 @@
 here');%0A
-%09
 %09%09consol
@@ -575,160 +575,33 @@
 );%0A%09
-%09%7D);%0A%09%7D);%0A%0A%09%0A%0A%09/*%0A%09fs.stat(socketPath, function (err) %7B%0A%09%09if (!err) %7B%0A%09%09%09fs.unlinkSync(socketPath);%0A%09%09%09return;%0A%09%09%7D%0A%0A%09%09var unixServer = net.createServer(
+%7D);%0A%0A%09client.on('error', 
 func
@@ -610,181 +610,66 @@
 on (
-sock
+error
 ) %7B%0A%09%09
-%09sock.write('show health');%0A%0A%09%09%09sock.on('data', function (data) %7B%0A%09%09%09%09winston.debug('DATA: '+data);%0A%09%09%09%09sock.destroy(
+console.log('Error Connection: '+error
 );%0A
-%09%09
 %09%7D);%0A%0A
-%09%09%7D).listen(socketPath);%0A%09%7D);%0A%09*/%0A%0A
 %09res

Add error checking method