Last active
December 27, 2015 02:19
-
-
Save yi/7251855 to your computer and use it in GitHub Desktop.
coffeescript kue redis createClient with custom host and port
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 更新外部配置 | |
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