Permalink
Browse files

Merge branch 'xtlessinstaller' into 19296

  • Loading branch information...
2 parents 2dbbc5d + bdb897d commit 71f322d5251d918a57dc14d3170a95ea1fcb0f29 @bendiy committed Apr 1, 2013
@@ -10,23 +10,27 @@
-- [ START ] xt
-- xt tables
-\i xt/tables/bicache.sql
+-- These need to be in the correct order for them to load based on dependant columns.
\i xt/tables/datasource.sql
\i xt/tables/dbserver.sql
\i xt/tables/ext.sql
-\i xt/tables/oa2client.sql
-\i xt/tables/oa2clientredirs.sql
-\i xt/tables/oa2token.sql
\i xt/tables/org.sql
\i xt/tables/orgext.sql
-- TODO Remove session in a future version after it has had time to be dropped.
\i xt/tables/session.sql
\i xt/tables/sessionorg.sql
\i xt/tables/sessionstore.sql
+
\i xt/tables/usr.sql
\i xt/tables/usrorg.sql
+\i xt/tables/oa2client.sql
+\i xt/tables/oa2clientredirs.sql
+\i xt/tables/oa2token.sql
+
+\i xt/tables/bicache.sql
+
-- xt functions
\i xt/functions/add_priv.sql
@@ -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);
}());
@@ -1,18 +1,36 @@
/*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 */
-
-require('../xt/foundation/foundation');
-require('../xt/database/database');
+/*global X:true, XT:true, _:true */
(function () {
"use strict";
- var _path = X.path, _ = X._, _fs = X.fs, initSocket, testConnection, dive,
- parseFile, calculateDependencies, dependenciesFor, checkDependencies, cleanse,
- installQueue, submit, existing, findExisting, install, select, refresh, runOrmInstaller;
-
- X.db = X.Database.create();
+ var _path = X.path,
+ _ = X._,
+ _fs = X.fs,
+ calculateDependencies,
+ checkDependencies,
+ cleanse,
+ dependenciesFor,
+ dive,
+ existing,
+ findExisting,
+ install,
+ installQueue,
+ parseFile,
+ refresh,
+ runOrmInstaller,
+ select,
+ 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) {
var ret = _.clone(orm);
@@ -111,7 +129,9 @@ require('../xt/database/database');
// this is the actual callback! The first arg is an error, which is null if
// we've made it this far. The second arg is an array of all the orm names
// that have been installed.
- return ack(null, _.map(socket.installed, function (orm) {return orm.type}));
+ return ack(null, _.map(socket.installed, function (orm) {
+ return orm.type;
+ }));
}
orm = queue.shift();
@@ -5,8 +5,6 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
(function () {
"use strict";
- var _ = X._;
-
/**
Functionality for dealing with postgres
@@ -30,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 () {

0 comments on commit 71f322d

Please sign in to comment.