Search code examples
redisnpmgulpredis-server

Start redis server using gulp


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?


Solution

  • 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);
        }
      });
    });