mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
try again
This commit is contained in:
parent
1920d44e54
commit
7876692706
17
redis.js
Normal file
17
redis.js
Normal file
@ -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();
|
||||
}
|
||||
}}
|
43
shots.js
43
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 || '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user