Skip to content

Commit

Permalink
WF plug - exit on unexpected error
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeTWC1984 committed Mar 4, 2024
1 parent 602e9a7 commit 712b128
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const request = new PixlRequest();
const he = require('he');
const {EOL} = require('os')
const JSONStream = require('pixl-json-stream');
const { profileEnd } = require('console');

let bullet = '>' // '⬤'

Expand Down Expand Up @@ -381,6 +382,7 @@ stream.on('json', function (job) {
})

function getNiceTitle(job, id) {
if(!job) return ''
let title = '<b> ' + job.seq + ' :: ' + (job.title || 'Unknown') + '</b>'
// if(id) title = `${id} :: ${title} `
// if(job.arg) title = title + ' :: ' + job.arg
Expand All @@ -406,7 +408,7 @@ stream.on('json', function (job) {
jobStatus[key].start,
niceInterval(jobStatus[key].elapsed),
getNiceStatus(jobStatus[key]), // status
key === jobStatus[key].event ? '' : `<i id="view_${key}" onclick="this.className = this.className == 'fa fa-eye' ? 'fa fa-eye-slash' : 'fa fa-eye'; $P().get_log_to_grid('${getNiceTitle(jobStatus[key], key)}', '${key}')" style="cursor:pointer" class="fa fa-eye"></i>`,
key === jobStatus[key].event ? '' : `<i id="view_${key}" onclick="this.className = this.className == 'fa fa-eye' ? 'fa fa-eye-slash' : 'fa fa-eye'; $P().get_log_to_grid(filterXSS(\`${getNiceTitle(jobStatus[key], key)}\`), '${key}')" style="cursor:pointer" class="fa fa-eye"></i>`,
//jobStatus[key].code ? `${he.encode(jobStatus[key].description)}`.substring(0,120) : ''
`${he.encode(jobStatus[key].description)}`.substring(0, 120)

Expand All @@ -428,6 +430,10 @@ stream.on('json', function (job) {

};

poll().catch(e => stream.write({ complete: 1, code: 1, description: e.message }));
poll().catch(e => {
stream.write({ complete: 1, code: 1, description: 'Plugin crashed: ' + e.message })
//if(process.connected) process.disconnect()
process.exit(1)
});

});

0 comments on commit 712b128

Please sign in to comment.