Created
September 13, 2019 15:55
-
-
Save gate3/f2da2986aef2bd740da72627ad89bae6 to your computer and use it in GitHub Desktop.
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
// Note i skipped a lot of steps here like starting a server etc | |
require('dotenv').config() | |
const redis = require('redis') | |
const sub = redis.createClient(); | |
const cp = require('child_process'); | |
const glob = require('glob'); | |
glob('!(node_modules)/**/*.worker.js', function (er, files) { // Ignore all workers in node_modules and use only those defined within my app | |
for (let f of files) { | |
cp.fork(`${__dirname}/${f}`); | |
} | |
}); | |
// Subscribe to the redis channel and anytime an event is fired get it and send to the client | |
const type = `channel:user` // Let listen on the user channel for example | |
sub.subscribe(type) | |
sub.on('message', function(channel, message){ | |
// Send a socketio event and listen on the client | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment