Skip to content

Instantly share code, notes, and snippets.

@djanowski
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djanowski/cfc662d64585b284db9c to your computer and use it in GitHub Desktop.
Save djanowski/cfc662d64585b284db9c to your computer and use it in GitHub Desktop.
git clone https://gist.github.com/djanowski/cfc662d64585b284db9c disque-crash
cd disque-crash
make
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
{
"name": "disque-crash",
"version": "0.0.1",
"private": true,
"main": "test.js",
"dependencies": {
"hiredis": "^0.3.0"
},
"scripts": {
"test": "node test.js"
}
}
'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