Created
December 31, 2018 06:27
-
-
Save aadityabhatia/0e9bfb076db33cbb3c964b6c5d375e57 to your computer and use it in GitHub Desktop.
Watch Redis pub/sub channels
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
| redis = require 'redis' | |
| client = redis.createClient | |
| HOST: process.env.HOST | |
| client.on 'error', (err) -> console.error err | |
| client.on 'subscribe', (channel, count) -> | |
| console.log "Subscribed:", channel | |
| client.on 'message', (channel, message) -> | |
| console.log channel, message | |
| client.on 'psubscribe', (pattern, count) -> | |
| console.log "Subscribed:", pattern | |
| client.on 'pmessage', (pattern, channel, message) -> | |
| console.log channel, message | |
| if process.argv.length > 2 | |
| for channel in process.argv.slice 2 | |
| client.subscribe channel | |
| else | |
| client.psubscribe '*' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment