Skip to content

Instantly share code, notes, and snippets.

@ascrutae
Created May 24, 2018 10:36
Show Gist options
  • Save ascrutae/19285ddfa20a52a69612184de739d3ed to your computer and use it in GitHub Desktop.
Save ascrutae/19285ddfa20a52a69612184de739d3ed to your computer and use it in GitHub Desktop.
require('skywalking-nodejs').start({
applicationCode: 'test'
});
let requestModule = require("request");
var http = require('http');
const port = 3001
callback = function (response) {
var str = ''
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
console.log(str);
});
}
const requestHandler = (request, response) => {
requestModule('http://localhost:3000/1', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
});
}
const server = http.createServer(requestHandler)
server.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`)
})
require('skywalking-nodejs').start({
applicationCode: 'test1'
});
const http = require('http')
var mysql = require('mysql');
const port = 3000
const requestHandler = (request, response) => {
var connection = mysql.createConnection({
host: 'localhost',
port: 3307,
user: 'root',
password: 'root',
database: 'test'
});
connection.connect();
connection.query('SELECT SLEEP(1)', function (error, results, fields) {
if (error) throw error;
connection = mysql.createConnection({
host: 'localhost',
port: 3307,
user: 'root',
password: 'root',
database: 'test'
});
connection.connect();
connection.query('SELECT SLEEP(3)', function (error, results, fields) {
if (error) throw error;
});
});
connection.query('SELECT SLEEP(2)', function (error, results, fields) {
if (error) throw error;
});
response.end("test");
}
const serverB = http.createServer(requestHandler)
serverB.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment