Skip to content
Manage app configurations, monitor deployments and emailing for node by Harald Rudell
Find file
New pull request
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Facilitates configuration, operation and service notifications for node.js applications


  1. Configure the apps in json from outside its source tree
  2. Single-line setup of operations details
  3. Email communications from your apps
  4. Monitor incoming requests with user agent string and origin
  5. Capture console output with log file output, rotate, and error stack traces
  6. Self-monitor by having multiple deployments monitor each other as well as external apps and Web locations
  7. Portably find function-specific folders and access the system browser
  8. Load app-specific json data from configurable out-of-source tree locations


  1. Flexible loading of out-of-source tree json data
  2. Email service wrapping various implementations including gmail
  3. Configurable heartbeat pinger-responder
  4. Express request logging
  5. stdout to file management
  6. OS portability layer


Loading per-machine configuration

var defaults = require('haraldops').init({appName: 'Node.js #3'})
  • Derives a filesystem friendly app identifier a-z0-9, in this case 'nodejs3'
  • Looks for a .json file by this name in $HOME/apps, $HOME or the folder the executing app is deployed to.
  • Loads the json and configures accordingly

The following values are known to be present in the returned object:

  • defaults.init.appName: string Name of the application eg. 'Node.js #3'
  • defaults.init.identifier: string Identifier to use eg. 'nodejs3'
  • defaults.init.appFolder: string Path to the apps folder eg. '/home/user/folder'
  • defaults.init.tmpFolder: string Path to a suitable temporary folder eg. '/home/user/tmp' or '/tmp'
  • defaults.init.homeFolder string Path to user's home folder eg. '/home/user'
  • defaults.init.logger function configured logging function

These top-level properties affects init:

  • logger: function, optional: log to this function, default is console.log
  • appName: string, optional: app name used, default is the name of the folder where the executing app is
  • identifier: string, optional: identifier used when locating settings files, default is derived from appName
  • NoFile: boolean, optional: if present and true, no file is loaded

Other properties are copied to the return value object

Properties loaded from file override those provided in argument


Sending Mail

using argument object:

var defaults = require('haraldops').init({
    haraldops: {
        mailsend: {
            user: '',
            pass: 'password',
            to: '',
    noFile: true,
defaults.init.ops.sendMail('subject', 'body')

Using a configuration file godo.json:

    "haraldops": {
        "mailsend": {
            "user": "",
            "pass": "password",
            "to": ""
var defaults = require('haraldops').init({appName: 'Go Do'})
defaults.init.ops.sendMail('subject', 'body')

Sample Configuration File

    "PORT": 3000,
    "haraldops": {
        "mailsend": {
            "user": "",
            "pass": "password",
            "to": ""
        "responder": "/status",
        "identifier": "thisapp",
        "pingers": [
                "title": "Make sure Google is up",
                "url": "",
                "isPingerList": false           
                "title": "Another deployment",
                "url": "",
                "app": "monitoredappidentifier"
    "fbAppSecret": "55555",
    "appInterface": "localhost",
    "sessionSecret": "verygreat",
    "ignoreUris": [

Monitoring of Google

Will send email if Google does not respond for 5 minutes

var ops = require('haraldops').opsconstructor({
    haraldops: {
        mailsend: {
            user: '',
            pass: 'password',
            to: '',
        pingers: [
                title: "Google",
                url: "",
                isPingerList: false
    noFile: true,   

Configuration Reference

  • haraldops.errorstack: true: adds
  • haraldops.logFile: '/tmp/x': copies console output to the provided file
  • haraldops.logRotate: 'day': period of rotation minute hour day month year

Function Reference

logrequest(logger, ignoreTheseUris)

var haraldops = require('haraldops')
var ignoreUris = [
    '/status', '/favicon.ico', /\/images.*/,
    /\/stylesheets.*/, /\/javascripts.*/,
app = express.createServer()
    app.use(haraldops.logrequest(console.log, ignoreUris))

Logs incoming requests. Handles load-balancer forwarding.

  • logger: a function that prints a single string argument
  • ignoreTheseUris a string, a regexp or an array of those types: do not log these requests

output: Time stamp, request method, host, client and user agent string

2012-05-16T23:11Z GET http://localhost:3000/ Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5

defaults.init.ops.sendMail(subject, body)

Send mail using the object returned by opsconstructor or mailconstructor.


Closes mail when all pending messages has been sent. Function property of the object returned by opsconstructor or mailconstructor.

defaults.init.ops.responder(app, url)

var haraldops = require('haraldops')
var o = {
    user: '', pass: 'secret', to: '',
    responder: '/status'
var opsObject = haraldops.opsconstructor(console.log, o)
var app = express.createServer()
opsObject.responder(app, o.responder)
  • app a server from connect or express
  • url a uri where server status is provided, eg. '/status'


  • optsArg
    • title: the printable name of the server being checked eg. 'My box'
    • url: the url for that server, eg. ''
    • period (optional, default 300): the number of seconds between each check
    • isPingerList (optional, default yes): if true the entire response is examined for times and consistency. If false, the response has to be error free and have status code 200
    • app the expected app identifier at that url


Deactivates the opsObject


Loads ~/haraldops.json and returns the json object

Something went wrong with that request. Please try again.