Skip to content

Commit

Permalink
(worker) added stop and isRunning methods to worker
Browse files Browse the repository at this point in the history
  • Loading branch information
inlife committed Mar 13, 2024
1 parent 7dfa1bf commit 4bb1650
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/nexrender-worker/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const NEXRENDER_API_POLLING = process.env.NEXRENDER_API_POLLING || 30 * 1000;
const NEXRENDER_TOLERATE_EMPTY_QUEUES = process.env.NEXRENDER_TOLERATE_EMPTY_QUEUES;
var emptyReturns = 0;

/* TODO: possibly add support for graceful shutdown */
let active = true;

const delay = amount => (
Expand Down Expand Up @@ -175,4 +174,20 @@ const start = async (host, secret, settings, headers) => {
} while (active)
}

module.exports = { start }
/**
* Stops worker "thread"
* @return {void}
*/
const stop = () => {
active = false;
}

/**
* Returns the current status of the worker
* @return {Boolean}
*/
const isRunning = () => {
return active;
}

module.exports = { start, stop, isRunning }

0 comments on commit 4bb1650

Please sign in to comment.