refs #4550 Changed updates
This commit is contained in:
parent
d3ca5c2e87
commit
7a2dbfa265
|
@ -2,6 +2,7 @@ debug: false
|
|||
log: true
|
||||
dryPrint: false
|
||||
keepFile: false
|
||||
serverId: 1
|
||||
concurrency: 4
|
||||
reconnectTimeout: 10
|
||||
refreshRate: 1000
|
||||
|
|
|
@ -9,7 +9,9 @@ const yml = require('require-yml');
|
|||
const selectQuery = fs.readFileSync(`sql/selectQueued.sql`).toString();
|
||||
const jobDataQuery = fs.readFileSync(`sql/jobData.sql`).toString();
|
||||
const jobArgsQuery = fs.readFileSync(`sql/jobArgs.sql`).toString();
|
||||
const updateQuery = fs.readFileSync(`sql/updateState.sql`).toString();
|
||||
const printingQuery = fs.readFileSync(`sql/updatePrinting.sql`).toString();
|
||||
const errorQuery = fs.readFileSync(`sql/updateError.sql`).toString();
|
||||
const printedQuery = fs.readFileSync(`sql/updatePrinted.sql`).toString();
|
||||
|
||||
class PrintServer {
|
||||
async start() {
|
||||
|
@ -165,7 +167,14 @@ class PrintServer {
|
|||
const [[printJob]] = await conn.query(selectQuery);
|
||||
if (printJob) {
|
||||
jobId = printJob.id;
|
||||
await conn.query(updateQuery, ['printing', null, jobId]);
|
||||
await conn.query(printingQuery, [
|
||||
'printing',
|
||||
now(),
|
||||
null,
|
||||
null,
|
||||
this.conf.serverId,
|
||||
jobId
|
||||
]);
|
||||
this.jobLog(jobId, 'debug', 'get: printing');
|
||||
await conn.commit();
|
||||
} else
|
||||
|
@ -274,11 +283,11 @@ class PrintServer {
|
|||
throw new Error(`Print error: ${err.message}`);
|
||||
}
|
||||
|
||||
await conn.query(updateQuery, ['printed', null, jobId]);
|
||||
await conn.query(printedQuery, ['printed', now(), jobId]);
|
||||
this.jobLog(jobId, 'log', `${jobData.report}: '${printCommand}': GET ${url}`);
|
||||
} catch (err) {
|
||||
try {
|
||||
await conn.query(updateQuery, ['error', err.message, jobId]);
|
||||
await conn.query(errorQuery, ['error', now(), err.message, jobId]);
|
||||
} catch (e) {
|
||||
this.jobLog(jobId, 'error', e.message);
|
||||
}
|
||||
|
@ -320,3 +329,7 @@ function pExec(command) {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
function now() {
|
||||
return new Date().toISOString().slice(0, 19).replace('T', ' ');
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
UPDATE vn.printQueue
|
||||
SET statusCode = ?,
|
||||
finished = ?,
|
||||
error = ?
|
||||
WHERE id = ?
|
|
@ -1,4 +1,4 @@
|
|||
UPDATE vn.printQueue
|
||||
SET statusCode = ?,
|
||||
error = ?
|
||||
finished = ?
|
||||
WHERE id = ?
|
|
@ -0,0 +1,7 @@
|
|||
UPDATE vn.printQueue
|
||||
SET statusCode = ?,
|
||||
`started` = ?,
|
||||
finished = ?,
|
||||
error = ?,
|
||||
serverId = ?
|
||||
WHERE id = ?
|
Loading…
Reference in New Issue