alpha-one
Version:
ideas about recurring tasks in Web- and Backend-Application building
34 lines (28 loc) • 1.67 kB
text/coffeescript
############################################################################################################
TRM = require 'coffeenode-trm'
rpr = TRM.rpr.bind TRM
badge = 'α1/validate-redis-is-running'
log = TRM.get_logger 'plain', badge
info = TRM.get_logger 'info', badge
whisper = TRM.get_logger 'whisper', badge
alert = TRM.get_logger 'alert', badge
debug = TRM.get_logger 'debug', badge
warn = TRM.get_logger 'warn', badge
help = TRM.get_logger 'help', badge
#...........................................................................................................
redis = require 'redis'
############################################################################################################
module.exports = ( options ) ->
client = redis.createClient options
#.........................................................................................................
client.on 'error', ( error ) ->
if /Redis connection to .* failed - connect ECONNREFUSED/.test error[ 'message' ]
alert """
you either forgot to start your Redis instance or it does not match the configuration:
#{rpr options}
"""
help "execute `redis-server` or demonize Redis"
throw error
#.........................................................................................................
client.set 'A1-test', 'test', ( error, response ) ->
info "Redis response: #{rpr response}"