Turn audio into a shareable video. forked from nypublicradio/audiogram

worker 947B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env node
  2. var dotenv = require("dotenv").config({silent: true}),
  3. Audiogram = require("../audiogram/"),
  4. transports = require("../lib/transports/");
  5. // Can only register fonts once, double-registering throws an error
  6. require("../lib/register-fonts.js");
  7. pluckJob();
  8. function pluckJob(){
  9. transports.getJob(function(err, settings){
  10. if (err) {
  11. throw err;
  12. }
  13. if (settings) {
  14. return render(settings);
  15. }
  16. setTimeout(pluckJob, delay());
  17. });
  18. }
  19. function render(settings) {
  20. var audiogram = new Audiogram(settings);
  21. audiogram.render(function(err){
  22. if (err) {
  23. audiogram.status("error");
  24. audiogram.set("error", err);
  25. throw err;
  26. }
  27. audiogram.status("ready");
  28. if (process.env.SPAWNED) {
  29. return transports.quit();
  30. }
  31. setTimeout(pluckJob, delay());
  32. });
  33. }
  34. function delay() {
  35. return transports.workerDelay ? transports.workerDelay() : 0;
  36. }