Skip to content

Commit 10776a0

Browse files
committed
Merge tag '1.38.2' into cdb
Version 1.38.2 2016-10-13 Bug fixes: * Batch queries: release redis clients to pool from locker and seeker.
2 parents f113c03 + 39b4bae commit 10776a0

File tree

110 files changed

+4828
-3338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+4828
-3338
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
before_script:
1+
before_install:
22
- lsb_release -a
3-
- sudo mv /etc/apt/sources.list.d/pgdg-source.list* /tmp
3+
- sudo mv /etc/apt/sources.list.d/pgdg.list* /tmp
44
- sudo apt-get -qq purge postgis* postgresql*
55
- sudo rm -Rf /var/lib/postgresql /etc/postgresql
66
- sudo apt-add-repository --yes ppa:cartodb/postgresql-9.5

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ jshint:
1313
@echo "***jshint***"
1414
@./node_modules/.bin/jshint app/ batch/ test/ app.js
1515

16-
TEST_SUITE := $(shell find test/{acceptance,unit} -name "*.js")
16+
TEST_SUITE := $(shell find test/{unit,integration,acceptance} -name "*.js")
1717
TEST_SUITE_UNIT := $(shell find test/unit -name "*.js")
18+
TEST_SUITE_INTEGRATION := $(shell find test/integration -name "*.js")
1819
TEST_SUITE_ACCEPTANCE := $(shell find test/acceptance -name "*.js")
20+
TEST_SUITE_BATCH := $(shell find test/*/batch -name "*.js")
1921

2022
test:
2123
@echo "***tests***"
@@ -25,10 +27,18 @@ test-unit:
2527
@echo "***unit tests***"
2628
@$(SHELL) test/run_tests.sh ${RUNTESTFLAGS} $(TEST_SUITE_UNIT)
2729

30+
test-integration:
31+
@echo "***integration tests***"
32+
@$(SHELL) test/run_tests.sh ${RUNTESTFLAGS} $(TEST_SUITE_INTEGRATION)
33+
2834
test-acceptance:
2935
@echo "***acceptance tests***"
3036
@$(SHELL) test/run_tests.sh ${RUNTESTFLAGS} $(TEST_SUITE_ACCEPTANCE)
3137

38+
test-batch:
39+
@echo "***batch queries tests***"
40+
@$(SHELL) test/run_tests.sh ${RUNTESTFLAGS} $(TEST_SUITE_BATCH)
41+
3242
test-all: jshint test
3343

3444
coverage:

NEWS.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,86 @@
1+
1.38.2 - 2016-10-13
2+
-------------------
3+
4+
Bug fixes:
5+
* Batch queries: release redis clients to pool from locker and seeker.
6+
7+
8+
1.38.1 - 2016-10-13
9+
-------------------
10+
11+
Enhancements:
12+
* Batch queries: improvements over leader locking.
13+
14+
15+
1.38.0 - 2016-10-11
16+
-------------------
17+
18+
Announcements:
19+
* Allow to set statement timeout per query in multi query batch queries.
20+
* Batch queries default statement timeout set to 12 hours.
21+
* Multiple queries jobs pushed as first job between queries.
22+
23+
24+
1.37.1 - 2016-10-05
25+
-------------------
26+
27+
Bug fixes:
28+
* Body parser accepting multipart requests.
29+
30+
31+
1.37.0 - 2016-10-04
32+
-------------------
33+
34+
Enhancements:
35+
* Migrate to Express.js 4.x series.
36+
37+
38+
1.36.2 - 2016-10-03
39+
-------------------
40+
41+
Bug fixes:
42+
- Batch Queries logs: use path instead of stream to be able to reopen FD.
43+
44+
45+
1.36.1 - 2016-09-30
46+
-------------------
47+
48+
Enhancements:
49+
* Tag fallback jobs logs.
50+
51+
52+
1.36.0 - 2016-09-30
53+
-------------------
54+
55+
New features:
56+
* Log queries from batch fallback jobs.
57+
58+
Enhancements:
59+
* assert.response following callback(err, obj) pattern.
60+
61+
62+
1.35.0 - 2016-09-15
63+
-------------------
64+
65+
New features:
66+
* Allow to use `--config /path/to/config.js` to specify configuration file.
67+
- Environment will be loaded from config file if `environment` key is present, otherwise it keeps current behaviour.
68+
69+
Bug fixes:
70+
* Allow to use absolute paths for log files.
71+
72+
Announcements:
73+
* Removes support for optional rollbar logging.
74+
75+
76+
1.34.2 - 2016-08-30
77+
-------------------
78+
79+
Announcements:
80+
* Upgrades cartodb-redis to 0.13.1.
81+
* Set TTL of finished job to 2h
82+
83+
184
1.34.1 - 2016-07-11
285
-------------------
386

app.js

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,65 +9,67 @@
99
* environments: [development, test, production]
1010
*
1111
*/
12-
var _ = require('underscore');
1312
var fs = require('fs');
1413
var path = require('path');
1514

16-
var ENV = process.env.NODE_ENV || 'development';
17-
18-
if (process.argv[2]) {
19-
ENV = process.argv[2];
15+
var argv = require('yargs')
16+
.usage('Usage: $0 <environment> [options]')
17+
.help('h')
18+
.example(
19+
'$0 production -c /etc/sql-api/config.js',
20+
'start server in production environment with /etc/sql-api/config.js as config file'
21+
)
22+
.alias('h', 'help')
23+
.alias('c', 'config')
24+
.nargs('c', 1)
25+
.describe('c', 'Load configuration from path')
26+
.argv;
27+
28+
var environmentArg = argv._[0] || process.env.NODE_ENV || 'development';
29+
var configurationFile = path.resolve(argv.config || './config/environments/' + environmentArg + '.js');
30+
if (!fs.existsSync(configurationFile)) {
31+
console.error('Configuration file "%s" does not exist', configurationFile);
32+
process.exit(1);
2033
}
2134

22-
process.env.NODE_ENV = ENV;
35+
global.settings = require(configurationFile);
36+
var ENVIRONMENT = argv._[0] || process.env.NODE_ENV || global.settings.environment;
37+
process.env.NODE_ENV = ENVIRONMENT;
2338

2439
var availableEnvironments = ['development', 'production', 'test', 'staging'];
2540

2641
// sanity check arguments
27-
if (availableEnvironments.indexOf(ENV) === -1) {
28-
console.error("\nnode app.js [environment]");
29-
console.error("environments: " + availableEnvironments.join(', '));
42+
if (availableEnvironments.indexOf(ENVIRONMENT) === -1) {
43+
console.error("node app.js [environment]");
44+
console.error("Available environments: " + availableEnvironments.join(', '));
3045
process.exit(1);
3146
}
3247

33-
// set Node.js app settings and boot
34-
global.settings = require(__dirname + '/config/settings');
35-
var env = require(__dirname + '/config/environments/' + ENV);
36-
env.api_hostname = require('os').hostname().split('.')[0];
37-
_.extend(global.settings, env);
48+
global.settings.api_hostname = require('os').hostname().split('.')[0];
3849

3950
global.log4js = require('log4js');
40-
var log4js_config = {
41-
appenders: [],
42-
replaceConsole:true
51+
var log4jsConfig = {
52+
appenders: [],
53+
replaceConsole: true
4354
};
4455

45-
if ( env.log_filename ) {
46-
var logdir = path.dirname(env.log_filename);
47-
// See cwd inlog4js.configure call below
48-
logdir = path.resolve(__dirname, logdir);
49-
if ( ! fs.existsSync(logdir) ) {
50-
console.error("Log filename directory does not exist: " + logdir);
56+
if ( global.settings.log_filename ) {
57+
var logFilename = path.resolve(global.settings.log_filename);
58+
var logDirectory = path.dirname(logFilename);
59+
if (!fs.existsSync(logDirectory)) {
60+
console.error("Log filename directory does not exist: " + logDirectory);
5161
process.exit(1);
5262
}
53-
console.log("Logs will be written to " + env.log_filename);
54-
log4js_config.appenders.push(
55-
{ type: "file", filename: env.log_filename }
63+
console.log("Logs will be written to " + logFilename);
64+
log4jsConfig.appenders.push(
65+
{ type: "file", absolute: true, filename: logFilename }
5666
);
5767
} else {
58-
log4js_config.appenders.push(
68+
log4jsConfig.appenders.push(
5969
{ type: "console", layout: { type:'basic' } }
6070
);
6171
}
62-
63-
if ( global.settings.rollbar ) {
64-
log4js_config.appenders.push({
65-
type: __dirname + "/app/models/log4js_rollbar.js",
66-
options: global.settings.rollbar
67-
});
68-
}
69-
70-
global.log4js.configure(log4js_config, { cwd: __dirname });
72+
global.log4js.configure(log4jsConfig);
7173
global.logger = global.log4js.getLogger();
7274

7375

@@ -78,12 +80,14 @@ if ( ! global.settings.base_url ) {
7880

7981
var version = require("./package").version;
8082

81-
var app = require(global.settings.app_root + '/app/app')();
82-
app.listen(global.settings.node_port, global.settings.node_host, function() {
83-
console.log(
84-
"CartoDB SQL API %s listening on %s:%s with base_url %s (%s)",
85-
version, global.settings.node_host, global.settings.node_port, global.settings.base_url, ENV
86-
);
83+
var server = require('./app/server')();
84+
var listener = server.listen(global.settings.node_port, global.settings.node_host);
85+
listener.on('listening', function() {
86+
console.info('Using configuration file "%s"', configurationFile);
87+
console.log(
88+
"CartoDB SQL API %s listening on %s:%s PID=%d (%s)",
89+
version, global.settings.node_host, global.settings.node_port, process.pid, ENVIRONMENT
90+
);
8791
});
8892

8993
process.on('uncaughtException', function(err) {
@@ -92,15 +96,19 @@ process.on('uncaughtException', function(err) {
9296

9397
process.on('SIGHUP', function() {
9498
global.log4js.clearAndShutdownAppenders(function() {
95-
global.log4js.configure(log4js_config);
99+
global.log4js.configure(log4jsConfig);
96100
global.logger = global.log4js.getLogger();
97101
console.log('Log files reloaded');
98102
});
103+
104+
if (server.batch && server.batch.logger) {
105+
server.batch.logger.reopenFileStreams();
106+
}
99107
});
100108

101109
process.on('SIGTERM', function () {
102-
app.batch.stop();
103-
app.batch.drain(function (err) {
110+
server.batch.stop();
111+
server.batch.drain(function (err) {
104112
if (err) {
105113
console.log('Exit with error');
106114
return process.exit(1);

app/controllers/health_check_controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ HealthCheckController.prototype.handleHealthCheck = function (req, res) {
2424
if (err) {
2525
response.err = err.message;
2626
}
27-
res.send(response, ok ? 200 : 503);
27+
res.status(ok ? 200 : 503).send(response);
2828

2929
});
3030
} else {
31-
res.send({enabled: false, ok: true}, 200);
31+
res.status(200).send({enabled: false, ok: true});
3232
}
3333
};
3434

0 commit comments

Comments
 (0)