Browse files

Better docs

  • Loading branch information...
1 parent 7c6a89f commit 17ae5421d0bba1d0893205fa3f128426d6fdbdf3 @jvinet jvinet committed Jan 9, 2012
Showing with 47 additions and 10 deletions.
  1. +47 −9
  2. +0 −1 janitor.js
@@ -1,16 +1,54 @@
## Janitor
-It keeps the things running at the right intervals. But different than cron.
+Janitor is a program somewhat similar to cron. Unlike cron, Janitor
+cannot run programs at specific times, only at intervals (eg, every 5
+minutes, or every 2 seconds).
-Janitor is built on NodeJS.
+Janitor has a unique spin, however: It can also run programs *after*
+another program has completed. This is quite useful in scenarios where you
+have a number of programs that need to be run at regular intervals and in
+a specific order.
-With Janitor, you can schedule commands to run at specific intervals (eg,
-every 30 seconds). You can also schedule commands to run after other
-commands have completed.
+In addition to relative scheduling, Janitor also provides basic watchdog
+capabilities. When Janitor starts up, it will start all watched processes,
+and if one dies, it will attempt to restart it and notify you.
-At Bet Smart, we use the Janitor to run a number of post-processing
-tasks after a data feed has been consumed.
-Janitor also provides basic watchdog capabilities. If a process dies,
-Janitor will restart it and notify the admin.
+### Example: Scheduling
+Say you have a script that fetches an external XML data feed, processes
+it, and loads it into your local database. Once the ETL process is
+complete, you want to perform some post-processing actions on it.
+This is an ideal use case for Janitor. You can accomplish this with the
+following configuration excerpt:
+ "schedule": {
+ "etl": {"cmd":"etl.js", "when":"every 60s"},
+ "postproc1": {"cmd":"pp1.js", "when":"after postproc1"},
+ "postproc2": {"cmd":"pp2.js", "when":"after postproc1"}
+ }
+### Example: Watchdog
+This excerpt will log all output from the script to a file. If
+the script dies, it will restart it and notify the administrator.
+ "admin": "",
+ "daemon": true,
+ "log": "janitor.log",
+ "pid": "",
+ "watch": {
+ "watch1": {"cmd":"", "notify":true, "output":"watch1.log"}
+ }
@@ -15,7 +15,6 @@
* This code works on NodeJS 0.4.12.
* TODO: use nodules for hot-loading config?
- * TODO: docs
var sys = require("sys");

0 comments on commit 17ae542

Please sign in to comment.