Skip to content

Commit

Permalink
Merge pull request #318 from veg/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
stevenweaver authored Nov 3, 2023
2 parents febf83a + b84fcd1 commit 37ad316
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions lib/jobstatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const spawn = require("child_process").spawn,
logger = require("./logger").logger;

var JobStatus = function(job_id) {

var self = this;

self.metronome = 0;
Expand All @@ -21,12 +20,10 @@ var JobStatus = function(job_id) {
W: "waiting",
S: "suspended"
};

};

// Define the status-returning function.
JobStatus.prototype.returnJobStatus = function(job_id, callback) {

var self = this;
self.callback = callback;
self.job_id = job_id;
Expand All @@ -49,8 +46,12 @@ JobStatus.prototype.returnJobStatus = function(job_id, callback) {
// If the job exists, check and return its status. If it is complete, stop
// the metronome.

qstat.stdout.on("data", function(data) {
qstat.on("error", function(err) {
self.error = "Error spawning qstat: " + err.message;
callback(self.error, self.status); // Pass the error to the callback
});

qstat.stdout.on("data", function(data) {
var job_status = null;
var job_ctime = null;
var job_stime = null;
Expand Down Expand Up @@ -102,7 +103,6 @@ JobStatus.prototype.returnJobStatus = function(job_id, callback) {
// If the job doesn't exist, return that information and stop the metronome.
// If some other error occurs, say so.
qstat.stderr.on("data", function(data) {

logger.info(self.job_id + " " + data);

var doesnt_exist =
Expand All @@ -115,13 +115,10 @@ JobStatus.prototype.returnJobStatus = function(job_id, callback) {
}

self.callback(self.error, self.status);

});

};

JobStatus.prototype.fullJobInfo = function(callback) {

var self = this;

self.callback = callback;
Expand All @@ -143,6 +140,11 @@ JobStatus.prototype.fullJobInfo = function(callback) {

var qstat = spawn("qstat", ["-f", self.job_id]);

qstat.on("error", function(err) {
self.error = "Error spawning qstat: " + err.message;
callback(self.error, self.status); // Pass the error to the callback
});

qstat.stdout.on("data", function(data) {
var job_status = translateQstat(data.toString());
self.callback(self.error, job_status);
Expand All @@ -155,11 +157,9 @@ JobStatus.prototype.fullJobInfo = function(callback) {
self.error = self.job_id + " no longer exists in the queue";
self.callback(self.error, "");
});

};

JobStatus.prototype.watch = function(callback) {

var self = this;

var metronome = new setInterval(
Expand All @@ -170,7 +170,6 @@ JobStatus.prototype.watch = function(callback) {
);

return metronome;

};

exports.JobStatus = JobStatus;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "datamonkey-js-server",
"description": "",
"version": "2.4.0",
"version": "2.4.1",
"engines": {
"node": ">=13"
},
Expand Down

0 comments on commit 37ad316

Please sign in to comment.