Skip to content

Commit

Permalink
sync to 0.9.35
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeTWC1984 committed Oct 5, 2023
1 parent 180f01e commit 962d2e5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 97 deletions.
10 changes: 5 additions & 5 deletions bin/url-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ stream.on('json', function(job) {
// timeout
request.setTimeout( (params.timeout || 0) * 1000 );

// ssl cert bypass
if (params.ssl_cert_bypass) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
}

if (!params.url || !params.url.match(/^https?\:\/\/\S+$/i)) {
stream.write({ complete: 1, code: 1, description: "Malformed URL: " + (params.url || '(n/a)') });
return;
Expand Down Expand Up @@ -67,6 +62,11 @@ stream.on('json', function(job) {
var opts = {
method: params.method
};

// ssl cert bypass
if (params.ssl_cert_bypass) {
opts.rejectUnauthorized = true;
}

// post data
if (opts.method == 'POST') {
Expand Down
15 changes: 12 additions & 3 deletions lib/comm.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,19 @@ module.exports = Class.create({
// start listening for websocket connections
this.numSocketClients = 0;
this.sockets = {};
this.io = SocketIO({ serveClient: false });
let io = this.io = SocketIO({ serveClient: false });

this.io.attach( this.web.http );
if (this.web.https) this.io.attach( this.web.https );
if (this.web.listeners) {
// modern pixl-server-web
this.web.listeners.forEach( function(listener) {
io.attach( listener );
} );
}
else {
// legacy pixl-server-web
this.io.attach( this.web.http );
if (this.web.https) this.io.attach( this.web.https );
}

this.io.on('connection', this.handleNewSocket.bind(this) );
},
Expand Down
88 changes: 1 addition & 87 deletions lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ module.exports = Class.create({
// construct http client for web hooks and uploading logs
this.request = new Request("Cronicle " + this.server.__version);

// optionally bypass all ssl cert validation
if (this.server.config.get('ssl_cert_bypass') || this.server.config.get('web_hook_ssl_cert_bypass')) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
}

// register our class as an API namespace
this.api.addNamespace("app", "api_", this);

Expand Down Expand Up @@ -1402,8 +1397,7 @@ module.exports = Class.create({
if (info.length > max_rows) {
// list has grown too long, needs a trim
self.logDebug(3, "List " + list_path + " has grown too long, trimming to max: " + max_rows, info);
// self.storage.listSplice( list_path, max_rows, info.length - max_rows, null, callback );
self.listRoughChop(list_path, max_rows, callback);
self.storage.listSplice( list_path, max_rows, info.length - max_rows, null, callback );
}
else {
// no trim needed, proceed to next list
Expand Down Expand Up @@ -1432,86 +1426,6 @@ module.exports = Class.create({
}
},

listRoughChop: function (list_path, max_rows, callback) {
// Roughly chop the end of a list to get the size down to under specified ceiling.
// This is not exact, and will likely be off by up to one 'page_size' of items.
// The idea here is to chop without using tons of memory like listSplice does.
const self = this;
this.logDebug(4, "Roughly chopping list: " + list_path + " down to max: " + max_rows);

self.storage._listLock(list_path, true, function () {
// list is now locked, we can work on it safely

self.storage.listGetInfo(list_path, function (err, list) {
// check for error
if (err) {
self.logError('maint', "Failed to load list header: " + list_path + ": " + err);
self.storage._listUnlock(list_path);
return callback();
}

// begin chop loop
async.whilst(
function () {
// keep chopping while list is too long
return (list.length > max_rows);
},
function (callback) {
// load last page
self.storage._listLoadPage(list_path, list.last_page, false, function (err, page) {
if (err) {
// this should never happen, and is bad
// (list is probably corrupted, and should be deleted and recreated)
return callback(new Error("Failed to load list page: " + list_path + "/" + list.last_page + ": " + err));
}
if (!page) page = { items: [] };
if (!page.items) page.items = [];

list.length -= page.items.length;

self.logDebug(5, "Deleting list page: " + list_path + "/" + list.last_page + " (" + page.items.length + " items)");

self.storage.delete(list_path + "/" + list.last_page, function (err) {
if (err) {
// log error but don't fail entire op
self.logError('maint', "Failed to delete list page: " + list_path + "/" + list.last_page + ": " + err);
}

list.last_page--;
callback();

}); // delete page
}); // _listLoadPage
},
function (err) {
// all done
if (err) {
self.logError('maint', err.toString());
self.storage._listUnlock(list_path);
return callback();
}

// update list header with new length and last_page
self.storage.put(list_path, list, function (err) {
if (err) {
self.logError('maint', "Failed to update list header: " + list_path + ": " + err);
}

// unlock list
self.storage._listUnlock(list_path);

self.logDebug(4, "List chop complete: " + list_path + ", new size: " + list.length, list);

// and we're done
callback();

}); // put
} // done
); // whilst
}); // listGetInfo
}); // listLock
},

archiveLogs: function () {
// archive all logs (called once daily)
const self = this;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cronicle-edge",
"version": "1.7.2",
"version": "1.7.3",
"description": "A simple, distributed task scheduler and runner with a web based UI.",
"author": "Joseph Huckaby <[email protected]>",
"homepage": "https://github.com/jhuckaby/Cronicle",
Expand Down Expand Up @@ -62,7 +62,7 @@
"pixl-server": "^1.0.40",
"pixl-server-api": "^1.0.2",
"pixl-server-storage": "^3.1.12",
"pixl-server-web": "^1.3.20",
"pixl-server-web": "^1.3.22",
"pixl-tools": "^1.0.29",
"pixl-webapp": "^2.0.2",
"read-last-lines": "^1.8.0",
Expand Down

0 comments on commit 962d2e5

Please sign in to comment.