-
Notifications
You must be signed in to change notification settings - Fork 3
/
valgrind.js
46 lines (40 loc) · 1.1 KB
/
valgrind.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2018-2019, NuoDB, Inc.
// All rights reserved.
//
// Redistribution and use permitted under the terms of the 3-clause BSD license.
'use strict';
const { Driver } = require('.');
const config = require('./test/config.js');
const http = require('http');
var driver = new Driver();
const port = 3000;
let server = http.createServer(function (request, response) {
if (request.url === '/') {
driver.connect(config, function (err, connection) {
if (err) {
console.log('failed to create a connection: ' + err);
return;
}
connection.readOnly = true;
connection.autoCommit = false;
connection.close(function (err) {
if (err) {
console.log('failed to close connection: ' + err);
}
response.end('closed connection!');
});
});
}
if (request.url === '/exit') {
server.close(function () {
console.log('server closed!');
process.exit();
});
}
});
server.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`)
})