Skip to content

Commit

Permalink
Version 0.9.14
Browse files Browse the repository at this point in the history
- Fixed issue with newest pixl-server-storage and @aws-sdk/client-s3 library.
  • Loading branch information
jhuckaby committed Oct 26, 2022
1 parent 2085e2c commit 8e8e348
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 43 deletions.
90 changes: 48 additions & 42 deletions lib/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -1155,53 +1155,59 @@ module.exports = Class.create({
// get read stream and prepare to compress it
var stream = fs.createReadStream( job.log_file );
var gzip = zlib.createGzip( self.server.config.get('gzip_opts') || {} );
stream.pipe( gzip );
var temp_file = job.log_file + '.gz';
var temp_stream = fs.createWriteStream( temp_file );

self.storage.putStream( path, gzip, function(err) {
if (err) {
self.logError('storage', "Failed to store job log: " + path + ": " + err);
if (callback) callback(err);
return;
}

self.logDebug(9, "Job log stored successfully: " + path);
stream.pipe( gzip ).pipe( temp_stream ).on("finish", function() {
var new_stream = fs.createReadStream( temp_file );

// delete or move local log file
if (self.server.config.get('copy_job_logs_to')) {
var dargs = Tools.getDateArgs( Tools.timeNow() );
var dest_path = self.server.config.get('copy_job_logs_to').replace(/\/$/, '') + '/';
if (job.event_title) dest_path += job.event_title.replace(/\W+/g, '') + '.';
dest_path += job.id + '.' + (dargs.yyyy_mm_dd + '-' + dargs.hh_mi_ss).replace(/\W+/g, '-');
dest_path += '.log';
self.storage.putStream( path, new_stream, function(err) {
fs.unlink( temp_file, function(err) {;} );
if (err) {
self.logError('storage', "Failed to store job log: " + path + ": " + err);
if (callback) callback(err);
return;
}

self.logDebug(9, "Moving local file: " + job.log_file + " to: " + dest_path);
self.logDebug(9, "Job log stored successfully: " + path);

self.logger.rotate( job.log_file, dest_path, function(err) {
if (err) {
self.logError('file', "Failed to move local job log file: " + job.log_file + ": " + err);
fs.unlink( job.log_file, function(err) {;} );
}
else {
self.logDebug(9, "Successfully moved local job log file: " + job.log_file + ": " + dest_path);
}
if (callback) callback();
} );
}
else {
self.logDebug(9, "Deleting local file: " + job.log_file);
fs.unlink( job.log_file, function(err) {
// all done
if (err) {
self.logError('file', "Failed to delete local job log file: " + job.log_file + ": " + err);
}
else {
self.logDebug(9, "Successfully deleted local job log file: " + job.log_file);
}
if (callback) callback();
// delete or move local log file
if (self.server.config.get('copy_job_logs_to')) {
var dargs = Tools.getDateArgs( Tools.timeNow() );
var dest_path = self.server.config.get('copy_job_logs_to').replace(/\/$/, '') + '/';
if (job.event_title) dest_path += job.event_title.replace(/\W+/g, '') + '.';
dest_path += job.id + '.' + (dargs.yyyy_mm_dd + '-' + dargs.hh_mi_ss).replace(/\W+/g, '-');
dest_path += '.log';

} ); // fs.unlink
} // delete
} ); // storage put
self.logDebug(9, "Moving local file: " + job.log_file + " to: " + dest_path);

self.logger.rotate( job.log_file, dest_path, function(err) {
if (err) {
self.logError('file', "Failed to move local job log file: " + job.log_file + ": " + err);
fs.unlink( job.log_file, function(err) {;} );
}
else {
self.logDebug(9, "Successfully moved local job log file: " + job.log_file + ": " + dest_path);
}
if (callback) callback();
} );
}
else {
self.logDebug(9, "Deleting local file: " + job.log_file);
fs.unlink( job.log_file, function(err) {
// all done
if (err) {
self.logError('file', "Failed to delete local job log file: " + job.log_file + ": " + err);
}
else {
self.logDebug(9, "Successfully deleted local job log file: " + job.log_file);
}
if (callback) callback();

} ); // fs.unlink
} // delete
} ); // storage put
}); // stream pipe
} ); // read file
} // master
else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Cronicle",
"version": "0.9.13",
"version": "0.9.14",
"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

0 comments on commit 8e8e348

Please sign in to comment.