- Notifications
You must be signed in to change notification settings - Fork219
agenda/agendash
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A Dashboard forAgenda.
- Job status auto-refreshes: 60-second polling by default.
- Schedule a new job from the UI.
- Dive in to see more details about the job, like the json data.
- Requeue a job. Clone the data and run immediately.
- Delete jobs. Useful for cleaning up old completed jobs.
- Search jobs by name and metadata. Supports querying by Mongo Object Id.
- Pagination
- Responsive UI
It may be required to create the following index for faster sorting (see#24)
db.agendaJobs.ensureIndex({ "nextRunAt" : -1, "lastRunAt" : -1, "lastFinishedAt" : -1}, "agendash")
- Get more test coverage
- Add middlewares for fastify, and other express-like libraries
- You decide! Submit a feature request
npm install --save agendash
Note:Agendash
requires mongodb version >2.6.0 to perform the needed aggregate queries. This is your mongo database version, not your node package version! To check your database version, connect to mongo and rundb.version()
.
Agendash provides Express middleware you can use at a specified path, for example this willmake Agendash available on your site at the/dash
path. Note: Do not try to mount Agendashat the root level likeapp.use('/', Agendash(agenda))
.
varexpress=require("express");varapp=express();// ... your other express middleware like body-parservarAgenda=require("agenda");varAgendash=require("agendash");varagenda=newAgenda({db:{address:"mongodb://127.0.0.1/agendaDb"}});// or provide your own mongo client:// var agenda = new Agenda({mongo: myMongoClient})app.use("/dash",Agendash(agenda));// ... your other routes// ... start your server
By mounting Agendash as middleware on a specific path, you may provide yourown authentication for that path. For example if you have an authenticatedsession using passport, you can protect the dashboard path like this:
app.use("/dash",function(req,res,next){if(!req.user||!req.user.is_admin){res.send(401);}else{next();}},Agendash(agenda));
Other middlewares will come soon in the folder/lib/middlewares/
.You'll just have to update the last line to require the middleware you need:
app.use("/agendash",Agendash(agenda,{middleware:"connect",}));
Note that if you use a CSRF protection middleware likecsurf
, you might need toconfigure it off for Agendash-routes.
A minimum Node.js version 12 is required for@hapi/hapi
dependency.
npm i @hapi/inert @hapi/hapi
constagenda=newAgenda().database("mongodb://127.0.0.1/agendaDb","agendaJobs");constserver=require("@hapi/hapi").server({port:3002,host:"localhost",});awaitserver.register(require("@hapi/inert"));awaitserver.register(Agendash(agenda,{middleware:"hapi",}));awaitserver.start();
Then browse tohttp://localhost:3002/
.
npm i koa koa-bodyparser koa-router koa-static
constagenda=newAgenda().database("mongodb://127.0.0.1/agendaDb","agendaJobs");constKoa=require("koa");constapp=newKoa();constmiddlewares=Agendash(agenda,{middleware:"koa",});for(constmiddlewareofmiddlewares){app.use(middleware);}awaitapp.listen(3002);
Then browse tohttp://localhost:3002/
.
npm i fastify
constagenda=newAgenda().database("mongodb://127.0.0.1/agendaDb","agendaJobs");constFastify=require("fastify");constfastify=newFastify();fastify.register(Agendash(agenda,{middleware:"fastify"}););awaitfastify.listen(3002);
Then browse tohttp://localhost:3002/
.
Agendash comes with a standalone Express app which you can use like this:
./node_modules/.bin/agendash --db=mongodb://localhost/agendaDb --collection=agendaCollection --port=3002
or like this, for default collectionagendaJobs
and default port3000
:
./node_modules/.bin/agendash --db=mongodb://localhost/agendaDb
If you are using npm >= 5.2, then you can usenpx:
npx agendash --db=mongodb://localhost/agendaDb --collection=agendaCollection --port=3002
Then browse tohttp://localhost:3002/
.
Agendash can also be run within a Docker container like this:
docker run -p 3000:3000 \ --env MONGODB_URI=mongo://myUser:myPass@myHost/myDb \ --env COLLECTION=myAgendaCollection agenda/agendash
Then browse tohttp://localhost:3000/
.