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?

4

2 回答 2

3

您可以生成一个启动 redis 的子进程(这基本上只是运行用于启动 redis 实例的 bash 命令,因此您也可以为其添加不同的选项 - 就像您从终端启动它一样):

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);
    }
  });
});
于 2015-06-05T14:54:45.057 回答
0

如果您使用的是 OS X,您可以通过Homebrew安装 redis :

brew install redis

并将其调整为在操作系统启动期间启动,如 Homebrew 公式中所述:

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

我认为这更好也更容易,然后为启动/停止 redis 使用 Glup 发明不同的尖峰。

于 2015-03-07T08:44:21.593 回答