123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #!/usr/bin/env node
- var dotenv = require("dotenv").config({silent: true}),
- Audiogram = require("../audiogram/"),
- transports = require("../lib/transports/");
-
- // Can only register fonts once, double-registering throws an error
- require("../lib/register-fonts.js");
-
- pluckJob();
-
- function pluckJob(){
-
- transports.getJob(function(err, job){
-
- if (err) {
- throw err;
- }
-
- if (job) {
-
- return render(job);
-
- }
-
- setTimeout(pluckJob, delay());
-
- });
-
- }
-
- function render(job) {
-
- var audiogram = new Audiogram(job.id);
-
- audiogram.settings = job;
-
- audiogram.render(function(err){
-
- if (err) {
- audiogram.status("error");
- audiogram.set("error", err.toString());
- throw err;
- }
-
- audiogram.status("ready");
-
- if (process.env.SPAWNED) {
- return transports.quit();
- }
-
- setTimeout(pluckJob, delay());
-
- });
-
- }
-
- function delay() {
- return transports.workerDelay ? transports.workerDelay() : 0;
- }
|