"use strict";
var async = require("async"),
- exec = require('child_process').exec,
+ proc = require('child_process'),
path = require('path'),
os = require('os'),
winston = require('winston'),
var schemaPath = path.join(path.dirname(spec.source), "440_schema.sql");
winston.info("Building schema for database " + databaseName);
- exec("psql -U " + creds.username + " -h " + creds.hostname + " --single-transaction -p " +
- creds.port + " -d " + databaseName + " -f " + schemaPath,
- {maxBuffer: 40000 * 1024 /* 200x default */}, done);
+ proc.spawn("psql -U " + creds.username + " -h " + creds.hostname + " --single-transaction -p " +
+ creds.port + " -d " + databaseName + " -f " + schemaPath, done);
},
populateData = function (done) {
winston.info("Populating data for database " + databaseName + " from " + spec.source);
- exec("psql -U " + creds.username + " -h " + creds.hostname + " --single-transaction -p " +
- creds.port + " -d " + databaseName + " -f " + spec.source,
- {maxBuffer: 40000 * 1024 /* 200x default */}, done);
+ proc.spawn("psql -U " + creds.username + " -h " + creds.hostname + " --single-transaction -p " +
+ creds.port + " -d " + databaseName + " -f " + spec.source, done);
},
// use exec to restore the backup. The alternative, reading the backup file into a string to query
// doesn't work because the backup file is binary.
restoreBackup = function (done) {
- exec("pg_restore -U " + creds.username + " -h " + creds.hostname + " -p " +
+ proc.spawn("pg_restore -U " + creds.username + " -h " + creds.hostname + " -p " +
creds.port + " -d " + databaseName + " -j " + os.cpus().length + " " + spec.backup, function (err, res) {
if (err) {
console.log("ignoring restore db error", err);