Skip to content

Instantly share code, notes, and snippets.

@yi
Last active December 27, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yi/7251855 to your computer and use it in GitHub Desktop.
Save yi/7251855 to your computer and use it in GitHub Desktop.
coffeescript kue redis createClient with custom host and port
## 更新外部配置
p.version('0.0.1')
.option('-p, --port <n>', 'redis server port')
.option('-h, --host [VALUE]', 'redis server host')
.parse(process.argv)
p.port = parseInt(p.port) || 6379
p.host = p.host || "localhost"
kue = require 'kue'
redis = require 'redis'
kue.redis.createClient = ->
client = redis.createClient(p.port, p.host, {"retry_max_delay":3000})
client.on "error", (error) ->
console.error "[redis.on_error] #{error}"
client.on "end", ->
console.warn "[kue::redis client::on end]"
client.on "ready", ->
console.info "[kue::redis client::on ready] redis client @#{p.host}:#{p.port} is ready to server."
client.on "reconnecting", (info) ->
console.info "[kue::redis client::on reconnecting] redis client is reconnecting to datastore:#{p.host}:#{p.port}... delay:#{info.delay}, attempt:#{info.attempt}"
return client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment