3

Most of our front end development workflow is automated using gulp tasks. We're wondering if there is a way to create a gulp task for starting redis.

Currently we're using redis-server which we launch with redis-server. We'd like to be able do something like: gulp redis. What would this entail?

emersonthis
  • 32,822
  • 59
  • 210
  • 375

2 Answers2

3

you could spawn a child process that starts up redis (this basically just runs the bash command used to start up your redis instance, so you can add different options to it as well - like you would if you start it from your terminal):

var gulp = require('gulp');
var child_process = require('child_process');

gulp.task('redis-start', function() {
  child_process.exec('redis-server', function(err, stdout, stderr) {
    console.log(stdout);
    if (err !== null) {
      console.log('exec error: ' + err);
    }
  });
});
instance
  • 88
  • 1
  • 4
0

If you are using OS X you can install redis through Homebrew:

brew install redis

and adjust it to start during OS startup as described in Homebrew formula:

To have launchd start redis at login:
    ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

I think this is better and easy then invent different spikes for start/stop redis use Glup.

Maxim
  • 9,701
  • 5
  • 60
  • 108
  • Thanks but this doesn't really answer the original question (how to use gulp). Out of curiosity, why is it better to run redis constantly instead of being able to turn it on and off? Remember this is for development, so we also need to test things like redis being unavailable. – emersonthis Mar 07 '15 at 12:36