This commit is contained in:
theory 2014-03-17 05:42:30 -06:00
parent 7876692706
commit ac4ffec554
2 changed files with 10 additions and 8 deletions

View File

@ -1,17 +1,19 @@
module.exports = {install: function(done){ module.exports = {install: function(path, done){
var fs = require('fs') var fs = require('fs')
, child = require('child_process') , child = require('child_process')
, check = (fs.existsSync||require('path').existsSync); , check = (fs.existsSync||require('path').existsSync)
if(!check('./redis-stable')){ , server = path + '/redis-stable/src/redis-server';
child.exec('curl -O http://download.redis.io/redis-stable.tar.gz' if(!check(server)){
child.exec('cd ' + path
+ ' && ' + 'curl -O http://download.redis.io/redis-stable.tar.gz'
+ ' && ' + 'tar xvzf redis-stable.tar.gz' + ' && ' + 'tar xvzf redis-stable.tar.gz'
+ ' && ' + 'cd redis-stable' + ' && ' + 'cd redis-stable'
+ ' && ' + 'make' + ' && ' + 'make'
, function(e, r){ , function(e, r){
console.log('>>>>>>>>>>>>>>>>>', e, r); console.log('>>>>>>>>>>>>>>>>>', e, r);
done(); done(server);
}); });
} else { } else {
done(); done(server);
} }
}} }}

View File

@ -1,14 +1,14 @@
module.exports = require('theory') module.exports = require('theory')
('shot',function(a){ ('shot',function(a){
var redis, client; var redis, client;
require('./redis').install(function(){ require('./redis').install('/tmp', function(path){
console.log('>>>>>>>>>>>>>>>>>>>>>>>> DONE <<<<<<<<<<<<<<<<<<<<'); console.log('>>>>>>>>>>>>>>>>>>>>>>>> DONE <<<<<<<<<<<<<<<<<<<<');
redis = a.redis redis = a.redis
, client = redis.createClient(); , client = redis.createClient();
client.on('error', function(e){ client.on('error', function(e){
if(!(/ECONNREFUSED/).test(e)){ return } if(!(/ECONNREFUSED/).test(e)){ return }
if(redis.none){ return } if(redis.none){ return }
redis.path = '/usr/local/bin/redis-server'; redis.path = path || '/usr/local/bin/redis-server';
if(!(require('fs').existsSync||require('path').existsSync)(redis.path)){ if(!(require('fs').existsSync||require('path').existsSync)(redis.path)){
redis.none = true; redis.none = true;
return; return;