Last active
August 29, 2015 14:20
-
-
Save djanowski/cfc662d64585b284db9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://gist.github.com/djanowski/cfc662d64585b284db9c disque-crash | |
cd disque-crash | |
make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DIR?=./tmp | |
PORTS=7711 7712 | |
all: $(DIR) setup stop clean start test | |
$(DIR): | |
mkdir -p $@ | |
setup: | |
npm install | |
test: | |
node test.js || true | |
grep Guru $(DIR)/*.log || echo "Unable to crash Disque." | |
start: $(patsubst %,start-%,$(PORTS)) | |
while [ ! `disque cluster nodes | grep ' connected$$' | wc -l` -eq $(words $^) ]; do \ | |
sleep 0.1; \ | |
done | |
stop: $(patsubst %,stop-%,$(PORTS)) | |
clean: | |
rm -rf $(DIR) | |
mkdir $(DIR) | |
start-%: | |
disque-server \ | |
--port $* \ | |
--dir $(DIR) \ | |
--daemonize yes \ | |
--bind 127.0.0.1 \ | |
--loglevel notice \ | |
--pidfile disque.$*.pid \ | |
--appendfilename disque.$*.aof \ | |
--cluster-config-file disque.$*.nodes \ | |
--logfile disque.$*.log | |
disque -p $* CLUSTER MEET 127.0.0.1 7711 > /dev/null | |
stop-%: | |
pkill -f "disque-server 127.0.0.1:$*" || true | |
sleep 0.1 | |
.PHONY: test clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "disque-crash", | |
"version": "0.0.1", | |
"private": true, | |
"main": "test.js", | |
"dependencies": { | |
"hiredis": "^0.3.0" | |
}, | |
"scripts": { | |
"test": "node test.js" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const hiredis = require('hiredis'); | |
const disque = hiredis.createConnection('7711', '127.0.0.1'); | |
const CYCLE = 100000; | |
let count = 0; | |
disque.on('reply', function() { | |
count++; | |
if (count === CYCLE) { | |
disque.end(); | |
} | |
}); | |
for (let i = 0; i < CYCLE; i++) { | |
disque.write('ADDJOB', 'q1', 'foo', '0'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment