UNPKG

el-borracho-basic

Version:

One-line zero-config ElBorrachoJS UI+API+Stats metapackage

215 lines (192 loc) 6.57 kB
// Generated by IcedCoffeeScript 1.8.0-c var Borracho, ElBorrachoBasic, Queue, Redis, Skeleton, Stats, errify, iced, root, __iced_k, __iced_k_noop, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; iced = require('iced-runtime'); __iced_k = __iced_k_noop = function() {}; require("source-map-support/register"); Redis = require("ioredis"); errify = require("errify"); Skeleton = require("nextorigin-express-skeleton"); Queue = require("bull"); Borracho = require("el-borracho/router"); Stats = require("el-borracho-stats/router"); root = require("el-borracho-ui/asset-path"); ElBorrachoBasic = (function(_super) { __extends(ElBorrachoBasic, _super); ElBorrachoBasic.prototype.logPrefix = "(El Borracho)"; function ElBorrachoBasic(options) { var oneYear, _base, _base1, _base2, _base3; this.options = options != null ? options : {}; this.redis || (this.redis = this.options.redis || Redis.createClient()); (_base = this.options).address || (_base.address = "0.0.0.0"); if ((_base1 = this.options).api == null) { _base1.api = true; } if ((_base2 = this.options).stats == null) { _base2.stats = true; } if ((_base3 = this.options).ui == null) { _base3.ui = true; } if (this.options.ui) { this.options["static"] = { root: root }; if (process.env.NODE_ENV !== "development") { oneYear = 86400; this.options["static"].options = { maxAge: oneYear }; } } ElBorrachoBasic.__super__.constructor.call(this, options); this.debug("initializing basic"); } ElBorrachoBasic.prototype.initStats = function(callback) { var Store, Worker, ideally, name, names, queue, stats, store, ___iced_passed_deferral, __iced_deferrals, __iced_k; __iced_k = __iced_k_noop; ___iced_passed_deferral = iced.findDeferral(arguments); ideally = errify(callback); Worker = require("el-borracho-stats/worker"); Store = require("el-borracho/lib/redis-model"); store = new Store(this.redis); this.stats = {}; (function(_this) { return (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/home/charles/source/el-borracho-basic/src/el-borracho-basic.coffee", funcname: "ElBorrachoBasic.initStats" }); store.queueNames(ideally(__iced_deferrals.defer({ assign_fn: (function() { return function() { return names = arguments[0]; }; })(), lineno: 37 }))); __iced_deferrals._fulfill(); }); })(this)((function(_this) { return function() { var _i, _len; for (_i = 0, _len = names.length; _i < _len; _i++) { name = names[_i]; queue = new Queue(name, { redis: { opts: { createClient: function() { return _this.redis; } } } }); stats = new Worker({ queue: queue }); _this.stats[name] = stats; } return callback(); }; })(this)); }; ElBorrachoBasic.prototype.bindRoutes = function() { if (this.options.api) { this.routeApi(); } if (this.options.stats) { return this.routeStats(); } }; ElBorrachoBasic.prototype.routeApi = function() { var mount; mount = this.options.ui ? "/jobs" : "/"; this.borracho = new Borracho({ server: this.server, redis: this.redis }); return this.app.use(mount, this.borracho.router); }; ElBorrachoBasic.prototype.routeStats = function() { this.stats = new Stats({ server: this.server, redis: this.redis }); return this.app.use("/stats", this.stats.router); }; ElBorrachoBasic.prototype.listen = function() { var ideally, stats, _, ___iced_passed_deferral, __iced_deferrals, __iced_k, _arguments = arguments; __iced_k = __iced_k_noop; ___iced_passed_deferral = iced.findDeferral(arguments); ideally = errify(function(err) { throw err; }); (function(_this) { return (function(__iced_k) { if (_this.options.stats) { (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/home/charles/source/el-borracho-basic/src/el-borracho-basic.coffee", funcname: "ElBorrachoBasic.listen" }); _this.initStats(ideally(__iced_deferrals.defer({ lineno: 62 }))); __iced_deferrals._fulfill(); })(function() { var _ref; _ref = _this.stats; for (_ in _ref) { stats = _ref[_]; stats.listen(); } return __iced_k(); }); } else { return __iced_k(); } }); })(this)((function(_this) { return function() { return ElBorrachoBasic.__super__.listen.apply(_this, _arguments); }; })(this)); }; ElBorrachoBasic.prototype.close = function() { var stats, _, ___iced_passed_deferral, __iced_deferrals, __iced_k, _arguments = arguments; __iced_k = __iced_k_noop; ___iced_passed_deferral = iced.findDeferral(arguments); (function(_this) { return (function(__iced_k) { var _ref; __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/home/charles/source/el-borracho-basic/src/el-borracho-basic.coffee", funcname: "ElBorrachoBasic.close" }); _ref = _this.stats; for (_ in _ref) { stats = _ref[_]; if (stats != null) { stats.stop(__iced_deferrals.defer({ lineno: 68 })); } } __iced_deferrals._fulfill(); }); })(this)((function(_this) { return function() { return ElBorrachoBasic.__super__.close.apply(_this, _arguments); }; })(this)); }; return ElBorrachoBasic; })(Skeleton); module.exports = ElBorrachoBasic; //# sourceMappingURL=el-borracho-basic.js.map