Skip to content

Commit

Permalink
pencilblue#122 Distributed Plugin Install cleanup and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Hyder committed Jul 29, 2014
1 parent 25132ed commit 464dbc9
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 34 deletions.
19 changes: 0 additions & 19 deletions controllers/api/plugins/plugin_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,6 @@ PluginApiController.prototype.render = function(cb) {
* @param {Function} cb
*/
PluginApiController.prototype.install = function(uid, cb) {
var self = this;

// pb.plugins.installPlugin(uid, function(err, result) {
// if (util.isError(err)) {
// var data = [err.message];
// if (util.isArray(err.validationErrors)) {
// for(var i = 0; i < err.validationErrors.length; i++) {
// data.push(err.validationErrors[i].message);
// }
// }
// var content = BaseController.apiResponse(BaseController.API_FAILURE, util.format(self.ls.get('INSTALL_FAILED'), uid), data);
// cb({content: content, code: 400});
// return;
// }
//
// var content = BaseController.apiResponse(BaseController.API_SUCCESS, util.format(self.ls.get('INSTALL_SUCCESS'), uid));
// cb({content: content});
// });

var jobId = pb.plugins.installPlugin(uid);
var content = BaseController.apiResponse(BaseController.API_SUCCESS, '', jobId);
cb({content: content});
Expand Down
4 changes: 2 additions & 2 deletions include/dao/dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ DAO.prototype.deleteMatching = function(where, collection){
}

//output delete command
if(pb.log.isDebug()){
pb.log.debug("DAO: DELETE FROM "+collection+" WHERE "+JSON.stringify(where));
if(pb.config.db.query_logging){
pb.log.info("DAO: DELETE FROM "+collection+" WHERE "+JSON.stringify(where));
}

var promise = new Promise();
Expand Down
6 changes: 4 additions & 2 deletions include/service/jobs/async_job_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ var JobRunner = require('./job_runner.js');
* @constructor
* @extends JobRunner
*/
function AsyncJobRunner() {}
function AsyncJobRunner() {
AsyncJobRunner.super_.call(this);
}

//ineritance
util.inherits(AsyncJobRunner, JobRunner);
Expand Down Expand Up @@ -61,7 +63,7 @@ AsyncJobRunner.prototype.run = function(cb) {
var self = this;

var d = domain.create();
d.on('error', function(err) {console.log('here in error handler: '+err.stack);
d.on('error', function(err) {
self.processResults(err, null, cb);
});
d.run(function() {
Expand Down
7 changes: 4 additions & 3 deletions include/service/jobs/cluster_job_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var AsyncJobRunner = require('./async_job_runner.js');
* @extends AsyncJobRunner
*/
function ClusterJobRunner(){
AsyncJobRunner.constructor.apply(this, []);
ClusterJobRunner.super_.call(this);
}

//inheritance
Expand Down Expand Up @@ -112,8 +112,9 @@ ClusterJobRunner.prototype.processResults = function(err, results, cb) {
var self = this;
var finishUp = function(err, result) {

//only set done if we were the process that organized this uninstall.
if (self.isInitiator) {
//only set done if we were the process that organized this job.
//The second condition ensures we aren't a sub-job
if (self.isInitiator && self.getChunkOfWorkPercentage() === 1) {
self.onCompleted(err);
}
cb(err, result);
Expand Down
2 changes: 1 addition & 1 deletion include/service/jobs/plugins/plugin_available_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var PluginJobRunner = require('./plugin_job_runner.js');
* @extends PluginJobRunner
*/
function PluginAvailableJob(){
PluginJobRunner.constructor.apply(this, []);
PluginAvailableJob.super_.call(this);

//initialize
this.setParallelLimit(1);
Expand Down
2 changes: 1 addition & 1 deletion include/service/jobs/plugins/plugin_dependencies_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var PluginJobRunner = require('./plugin_job_runner.js');
* @extends PluginJobRunner
*/
function PluginDependenciesJob(){
PluginJobRunner.constructor.apply(this, []);
PluginDependenciesJob.super_.call(this);

//initialize
this.setParallelLimit(1);
Expand Down
3 changes: 2 additions & 1 deletion include/service/jobs/plugins/plugin_initialize_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var PluginJobRunner = require('./plugin_job_runner.js');
* @extends PluginJobRunner
*/
function PluginInitializeJob(){
PluginJobRunner.constructor.apply(this, []);
PluginInitializeJob.super_.call(this);

//initialize
this.setParallelLimit(1);
Expand Down Expand Up @@ -101,6 +101,7 @@ PluginInitializeJob.prototype.getWorkerTasks = function(cb) {
self.log('Initializing plugin %s', pluginUid);
pb.plugins.initPlugin(plugin, function(err, result) {
self.log('Completed initialization RESULT=[%s] ERROR=[%s]', result, err ? err.message : 'n/a');
callback(err, result);
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion include/service/jobs/plugins/plugin_install_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var PluginJobRunner = require('./plugin_job_runner.js');
* @extends PluginJobRunner
*/
function PluginInstallJob(){
PluginJobRunner.constructor.apply(this, []);
PluginInstallJob.super_.call(this);

//initialize
this.init();
Expand Down
2 changes: 1 addition & 1 deletion include/service/jobs/plugins/plugin_job_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var ClusterJobRunner = require('../cluster_job_runner.js');
* @extends ClusterJobRunner
*/
function PluginJobRunner() {
ClusterJobRunner.constructor.apply(this, []);
PluginJobRunner.super_.call(this);
};

//inheritance
Expand Down
2 changes: 1 addition & 1 deletion nodemon.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"verbose": false,
"ignore": ["public/media", "public/js", ".git", "log", "node_modules/**/node_modules"],
"ignore": ["public/media", "public/js", ".git", "log", "node_modules/**/node_modules","plugins/**/node_modules"],
"execMap": {
"rb": "ruby",
"pde": "processing --sketch={{pwd}} --run"
Expand Down
2 changes: 1 addition & 1 deletion public/js/admin/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function onUninstallSuccess(data) {
console.val(console.val()+toAppend);

//offset so we don't get repeats
starting = starting === nextStarting ? nextStarting + 1 : nextStarting;
starting = nextStarting + 1;

//check for more log entries
loghandle = setTimeout(doLogRetrieve, 2000);
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/elements/progress_console_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h4 class="modal-title" id="modal_label">^loc_PLEASE_WAIT^...</h4>
</div>
<div class="modal-body loading-modal-content">
<div id="progress_bar" class="progress progress-striped active">
<div id="bar" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
<div id="bar" class="progress-bar progress-bar-info" role="progressbar" aria-valuemin="0" aria-valuemax="100" style="width: 0"></div>
</div>
<textarea id="progress_console" rows="5" wrap="off"></textarea>
</div>
Expand Down

0 comments on commit 464dbc9

Please sign in to comment.