Skip to content

Instantly share code, notes, and snippets.

@mbbroberg
Forked from jcooklin/run-snapd.sh
Created January 5, 2016 21:59
Show Gist options
  • Save mbbroberg/1c9a5407ca1ea581847b to your computer and use it in GitHub Desktop.
Save mbbroberg/1c9a5407ca1ea581847b to your computer and use it in GitHub Desktop.
starts a snap tribe, loads plugins and starts a task
#!/bin/bash
typeset -i num
num=6
echo "starting seed"
$SNAP_PATH/bin/snapd --tribe --tribe-port 6000 --tribe-addr 127.0.0.1 --tribe-node-name seed --api-port 8181 -l 1 -t 0 --enable-instrumentation 2>&1 > /tmp/p-seed.out &
echo "starting $num snap agents"
for ((i=1;i<num;i++))
do
sleep .1
$SNAP_PATH/bin/snapd --tribe --tribe-port $((6000+${i})) --tribe-addr 127.0.0.1 --api-port $((8181+${i})) -l 1 --tribe-seed "127.0.0.1:6000" --tribe-node-name member-$i -t 0 --enable-instrumentation 2>&1 > /tmp/p-${i}.out &
done
#echo "waiting 2 seconds for everything to spin up"
#sleep 2
echo "add agreement"
curl -d '{"name": "asdf"}' http://127.0.0.1:8181/v1/tribe/agreements
echo "agents join agreement"
curl -X PUT -d '{"member_name": "seed"}' http://127.0.0.1:8181/v1/tribe/agreements/asdf/join
for ((i=1;i<num;i++))
do
curl -X PUT -d "{\"member_name\": \"member-$i\"}" http://127.0.0.1:8181/v1/tribe/agreements/asdf/join
done
#sleep 3
echo "Loading mock1"
$SNAP_PATH/bin/snapctl plugin load $SNAP_PATH/plugin/snap-collector-mock1
echo "Loading passthru"
$SNAP_PATH/bin/snapctl plugin load $SNAP_PATH/plugin/snap-processor-passthru
echo "Loading file publisher"
$SNAP_PATH/bin/snapctl plugin load $SNAP_PATH/plugin/snap-publisher-file
echo "Load task"
$SNAP_PATH/bin/snapctl task create -t $SNAP_PATH/../examples/tasks/mock-file.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment