npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

kue-service

v0.0.3

Published

*using the builing metaphor for this, all jobs have a site, this is where workers convene and are managed by a foreman. The Kue service has been wrapped to allow us to define a set of jobs in a site directory, each workers filenames match the job name, a

Downloads

7

Readme

#Kue Service

using the builing metaphor for this, all jobs have a site, this is where workers convene and are managed by a foreman. The Kue service has been wrapped to allow us to define a set of jobs in a site directory, each workers filenames match the job name, a .json file matching the workers name can be added to allow for settings and scheduling

NB - the queue-manager starts up a site, in a separate process - the idea is that we will allow for multiple processes to be run, in a cluster format in future, but for now if something goes wrong, ps -ef | grep node is your friend :)

thanks to the guys from kue and node-schedule for making this possible

#installation

npm install kue-service --save

#examples:

with directory structure:

test-site
    |__workers
        |__test.js
        |__test.json
    config.js

config.js:

var path = require('path');

module.exports = {
  workerPath:__dirname + path.sep + 'workers'
}

test.js

function TestWorker(){}

TestWorker.prototype.initialize = function(callback){
  this.__log.info('initialized test worker');
  callback();
}

TestWorker.prototype.start = function(callback){
  this.__log.info('started test worker');
  callback();
}

TestWorker.prototype.stop = function(callback){
  this.__log.info('stopped test worker');
  callback();
}

TestWorker.prototype.process = function(testjob, callback){
  this.__log.info('ran process function', testjob.data);
  testjob.data.addedField = 'test';
  callback(null, testjob.data);
}

TestWorker.prototype.test = function(callback){

  callback();
}

module.exports = TestWorker;

test.json - what is of interest here is that you can configure jobs to run according to a schedule, to see the schedule params check out: github.com/node-schedule/node-schedule

{
  "parameters":{
    "test":"param"
  },
  "schedule":{
    "params":{
      "second":[0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85.90,95]
    }
  }
}

you start the service like so, this is from the unit test - shows how a scheduled job runs:


var KueService = require('kue-service');
//path to your test site folder
var config = {site:__dirname + path.sep + 'test-sit'};

kueService = new KueService();
var runCount = 0;
kueService.start(config, function(e){
  if (e) return callback(e);

  kueService.queue.on('job complete', function(job){
    runCount++;
  });

  setTimeout(function(){

    return kueService.stop(function (e) {
      expect(runCount > 0).to.be(true);
      callback(e);
    });

  }, 15000);

});

you kick off a job explicitly by calling the queue:


var KueService = require('../lib/queue-manager');
var config = {site:__dirname + path.sep + 'test-site'};

kueService = new KueService();

kueService.start(config, function(e){
  if (e) return callback(e);

  var job = kueService.queue.create('test', {'test':'params'});

  job.on('complete', function(result){
    kueService.stop(callback);
  });

  job.save(function(e) {
      if (e) {
        console.warn('error queueing job', e);
        return kueService.stop(function (e) {
          callback(e);
        });
      }
    }
  );
});

#Disclaimer and license Use at own risk, MIT license