From 7876692706129d613fd8bca50b239194df266184 Mon Sep 17 00:00:00 2001 From: theory Date: Mon, 17 Mar 2014 05:26:25 -0600 Subject: [PATCH] try again --- redis.js | 17 +++++++++++++++++ shots.js | 43 ++++++++++++++++++++++--------------------- 2 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 redis.js diff --git a/redis.js b/redis.js new file mode 100644 index 00000000..708ea612 --- /dev/null +++ b/redis.js @@ -0,0 +1,17 @@ +module.exports = {install: function(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' + + ' && ' + 'tar xvzf redis-stable.tar.gz' + + ' && ' + 'cd redis-stable' + + ' && ' + 'make' + , function(e, r){ + console.log('>>>>>>>>>>>>>>>>>', e, r); + done(); + }); + } else { + done(); + } +}} \ No newline at end of file diff --git a/shots.js b/shots.js index ce649558..87227a22 100644 --- a/shots.js +++ b/shots.js @@ -1,29 +1,30 @@ module.exports = require('theory') ('shot',function(a){ - require('child_process').exec(__dirname+'/redis.sh', function(e, r){ - console.log(e,r); - }); - /* - var 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'; - if(!(require('fs').existsSync||require('path').existsSync)(redis.path)){ - redis.none = true; - return; - } - if(process.env.gun_redis_lock){ return } - process.env.gun_redis_lock = process.pid; - console.log('gun', process.pid, 'starting redis'); - require('child_process').spawn(redis.path).on('exit',function(c,s){ - if(process.env.gun_redis_lock == process.pid){ - process.env.gun_redis_lock = ''; // 0 and false don't work, cause they are cast to strings! + var redis, client; + require('./redis').install(function(){ + 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'; + if(!(require('fs').existsSync||require('path').existsSync)(redis.path)){ + redis.none = true; + return; } + if(process.env.gun_redis_lock){ return } + process.env.gun_redis_lock = process.pid; + console.log('gun', process.pid, 'starting redis'); + require('child_process').spawn(redis.path).on('exit',function(c,s){ + if(process.env.gun_redis_lock == process.pid){ + process.env.gun_redis_lock = ''; // 0 and false don't work, cause they are cast to strings! + } + }); }); + client.set("string key", "string val", redis.print); + client.get("string key", redis.print); }); - */ return function(opt){ opt = opt || {}; opt.src = opt.src || '';