     db = undefined
     async.series([
         (cb) ->
-            require('./rethink').rethinkdb
-                hosts : DB
-                pool  : 1
-                cb    : (err, x) ->
-                    db = x
-                    cb(err)
+            get_db (err, x) ->
+                db = x
+                cb(err)
         (cb) ->
             exports.save_BUP_age
                 database                 : db

# Command line interface
###########################

program     = require('commander')

LOGS = join(process.env.HOME, 'logs')
program.usage('[start/stop/restart/status] [options]')
    .option('--pidfile [string]', 'store pid in this file', String, "#{LOGS}/storage.pid")
    .option('--logfile [string]', 'write log to this file', String, "#{LOGS}/storage.log")
    .option('-e')   # gets passed by coffee -e
    .parse(process.argv)

main = () ->
    winston.debug("running as a deamon")
    daemon = require('start-stop-daemon')
    # run as a server/daemon (otherwise, is being imported as a library)

        winston.debug("Uncaught exception: " + err)
        winston.debug(err.stack)
        winston.debug("BUG ****************************************************************************")
        get_db (e, db) ->
            if not e
                db?.uncaught_exception(err)

    async.series([
        (cb) ->
