From ac4ffec554c82a76d1f060d9b17f4b5d5128d2e2 Mon Sep 17 00:00:00 2001 From: theory Date: Mon, 17 Mar 2014 05:42:30 -0600 Subject: [PATCH] go go go --- redis.js | 14 ++++++++------ shots.js | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/redis.js b/redis.js index 708ea612..1effe89f 100644 --- a/redis.js +++ b/redis.js @@ -1,17 +1,19 @@ -module.exports = {install: function(done){ +module.exports = {install: function(path, done){ var fs = require('fs') , child = require('child_process') - , check = (fs.existsSync||require('path').existsSync); - if(!check('./redis-stable')){ - child.exec('curl -O http://download.redis.io/redis-stable.tar.gz' + , check = (fs.existsSync||require('path').existsSync) + , server = path + '/redis-stable/src/redis-server'; + if(!check(server)){ + child.exec('cd ' + path + + ' && ' + 'curl -O http://download.redis.io/redis-stable.tar.gz' + ' && ' + 'tar xvzf redis-stable.tar.gz' + ' && ' + 'cd redis-stable' + ' && ' + 'make' , function(e, r){ console.log('>>>>>>>>>>>>>>>>>', e, r); - done(); + done(server); }); } else { - done(); + done(server); } }} \ No newline at end of file diff --git a/shots.js b/shots.js index 87227a22..a713ec7b 100644 --- a/shots.js +++ b/shots.js @@ -1,14 +1,14 @@ module.exports = require('theory') ('shot',function(a){ var redis, client; - require('./redis').install(function(){ + require('./redis').install('/tmp', function(path){ console.log('>>>>>>>>>>>>>>>>>>>>>>>> DONE <<<<<<<<<<<<<<<<<<<<'); redis = a.redis , client = redis.createClient(); client.on('error', function(e){ if(!(/ECONNREFUSED/).test(e)){ 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)){ redis.none = true; return;