refs #4550 Changed updates
This commit is contained in:
parent
d3ca5c2e87
commit
7a2dbfa265
|
@ -2,6 +2,7 @@ debug: false
|
||||||
log: true
|
log: true
|
||||||
dryPrint: false
|
dryPrint: false
|
||||||
keepFile: false
|
keepFile: false
|
||||||
|
serverId: 1
|
||||||
concurrency: 4
|
concurrency: 4
|
||||||
reconnectTimeout: 10
|
reconnectTimeout: 10
|
||||||
refreshRate: 1000
|
refreshRate: 1000
|
||||||
|
@ -15,4 +16,4 @@ db:
|
||||||
salix:
|
salix:
|
||||||
url: http://localhost:3000
|
url: http://localhost:3000
|
||||||
user: user
|
user: user
|
||||||
password: password
|
password: password
|
|
@ -9,7 +9,9 @@ const yml = require('require-yml');
|
||||||
const selectQuery = fs.readFileSync(`sql/selectQueued.sql`).toString();
|
const selectQuery = fs.readFileSync(`sql/selectQueued.sql`).toString();
|
||||||
const jobDataQuery = fs.readFileSync(`sql/jobData.sql`).toString();
|
const jobDataQuery = fs.readFileSync(`sql/jobData.sql`).toString();
|
||||||
const jobArgsQuery = fs.readFileSync(`sql/jobArgs.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 {
|
class PrintServer {
|
||||||
async start() {
|
async start() {
|
||||||
|
@ -165,7 +167,14 @@ class PrintServer {
|
||||||
const [[printJob]] = await conn.query(selectQuery);
|
const [[printJob]] = await conn.query(selectQuery);
|
||||||
if (printJob) {
|
if (printJob) {
|
||||||
jobId = printJob.id;
|
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');
|
this.jobLog(jobId, 'debug', 'get: printing');
|
||||||
await conn.commit();
|
await conn.commit();
|
||||||
} else
|
} else
|
||||||
|
@ -274,11 +283,11 @@ class PrintServer {
|
||||||
throw new Error(`Print error: ${err.message}`);
|
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}`);
|
this.jobLog(jobId, 'log', `${jobData.report}: '${printCommand}': GET ${url}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
try {
|
try {
|
||||||
await conn.query(updateQuery, ['error', err.message, jobId]);
|
await conn.query(errorQuery, ['error', now(), err.message, jobId]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.jobLog(jobId, 'error', e.message);
|
this.jobLog(jobId, 'error', e.message);
|
||||||
}
|
}
|
||||||
|
@ -319,4 +328,8 @@ function pExec(command) {
|
||||||
resolve({stdout, stderr})
|
resolve({stdout, stderr})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function now() {
|
||||||
|
return new Date().toISOString().slice(0, 19).replace('T', ' ');
|
||||||
}
|
}
|
|
@ -5,4 +5,4 @@ SELECT pq.id
|
||||||
AND r.method IS NOT NULL
|
AND r.method IS NOT NULL
|
||||||
ORDER BY pq.priorityFk ASC
|
ORDER BY pq.priorityFk ASC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
FOR UPDATE
|
FOR UPDATE
|
|
@ -0,0 +1,5 @@
|
||||||
|
UPDATE vn.printQueue
|
||||||
|
SET statusCode = ?,
|
||||||
|
finished = ?,
|
||||||
|
error = ?
|
||||||
|
WHERE id = ?
|
|
@ -1,4 +1,4 @@
|
||||||
UPDATE vn.printQueue
|
UPDATE vn.printQueue
|
||||||
SET statusCode = ?,
|
SET statusCode = ?,
|
||||||
error = ?
|
finished = ?
|
||||||
WHERE id = ?
|
WHERE id = ?
|
|
@ -0,0 +1,7 @@
|
||||||
|
UPDATE vn.printQueue
|
||||||
|
SET statusCode = ?,
|
||||||
|
`started` = ?,
|
||||||
|
finished = ?,
|
||||||
|
error = ?,
|
||||||
|
serverId = ?
|
||||||
|
WHERE id = ?
|
Loading…
Reference in New Issue