Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Installer running without errors on XT.dataSource.

  • Loading branch information...
commit 16b1fafe894fa8566f1f118a1da3e29cc6b7bd6f 1 parent 1698512
bendiy authored
31 node-datasource/installer/installer.js
View
@@ -1,12 +1,25 @@
#!/usr/bin/env node
/*jshint node:true, indent:2, curly:false, eqeqeq:true, immed:true, latedef:true, newcap:true, noarg:true,
regexp:true, undef:true, strict:true, trailing:true, white:true */
-/*global X:true */
+/*global X:true, XT:true, _:true */
+
+_ = require("underscore");
+
+require('../xt/foundation/foundation');
+require('../xt/database/database');
+
+if (typeof XT === 'undefined') {
+ XT = {};
+}
+
+if (!X.options) {
+ X.options = {};
+ X.options.datasource = {};
+}
(function () {
"use strict";
- var orm = require('./orm'),
- argv = process.argv,
+ var argv = process.argv,
credentials = {},
path = argv[argv.indexOf("--path") + 1];
@@ -27,5 +40,17 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
credentials.password = "";
}
+ // Use pgWorker.
+ if (argv.indexOf("-w") > -1) {
+ X.log("Using a seperate pgWorker process.");
+ X.options.datasource.pgWorker = true;
+ } else {
+ X.warn("Not using pgWorker process.");
+ X.warn("Use '-w' command line flag to enable it if you want to.");
+ }
+
+ // Require orm after X.options setting.
+ var orm = require('./orm');
+
orm.run(credentials, path);
}());
13 node-datasource/installer/orm.js
View
@@ -2,13 +2,6 @@
regexp:true, undef:true, strict:true, trailing:true, white:true */
/*global X:true, XT:true, _:true */
-XT = {};
-_ = require("underscore");
-
-require('../xt/foundation/foundation');
-require('../xt/database/database');
-require('../lib/ext/datasource');
-
(function () {
"use strict";
@@ -31,6 +24,12 @@ require('../lib/ext/datasource');
submit,
testConnection;
+ // When ran from the maintenance route, we already have XT.dataSource.
+ // When ran from the installer, we need to included it after X.options is set.
+ if (typeof XT.dataSource === 'undefined') {
+ require('../lib/ext/datasource');
+ }
+
X.db = XT.dataSource;
cleanse = function (orm) {
44 node-datasource/xt/database/database.js
View
@@ -28,50 +28,6 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
},
/**
- Perform query
-
- @param {String} query
- @param {Object} options
- @param {Function} callback
- */
- query: function (query, options, callback) {
- var str = this.conString(_.clone(options));
- X.pg.connect(str, _.bind(this.connected, this, query, options, callback));
- },
-
- /**
- * Connected.
- *
- * NOIE: This is only used when running the installer.
- */
- connected: function (query, options, callback, err, client, done, ranInit) {
- if (err) {
- issue(X.warning("Failed to connect to database: " +
- "{hostname}:{port}/{database} => %@".f(options, err.message)));
- done();
- return callback(err);
- }
-
- if (ranInit === true) {
- client.hasRunInit = true;
- }
-
- if (!client.hasRunInit) {
- client.query("set plv8.start_proc = \"xt.js_init\";", _.bind(
- this.connected, this, query, options, callback, err, client, done, true));
- } else {
-
- client.query(query, function (err, result) {
- // Release the client from the pool.
- done();
-
- // Call the call back.
- callback(err, result);
- });
- }
- },
-
- /**
Waits for database pool to drain and finishes cleanup
*/
cleanup: function () {
Please sign in to comment.
Something went wrong with that request. Please try again.