Allows you to simply manage (semi automatic) sharding of your discord bot running in a docker swarm (across multiple hosts)
For the master, you can simply use the docker image (greenbigfrog/shardmaster
). For the peers add the following to your shard.yml
:
dependencies:
shardmaster:
github: greenbigfrog/shardmaster
branch: master
View example/README.md
for more info
Run the master in a docker container called shardmaster
and has mutual network with the peers:
docker service create --name shardmaster --network net greenbigfrog/shardmaster /shardmaster 10
Get shard:
require "shardmaster/peer"
shard = Shardmaster::Peer.get_shard
shard_id = shard[:id]
num_shards = shard[:shard_count]
Post ping every < 5 minutes to keep the shard from expiring:
require "shardmaster/peer"
Shardmaster::Peer.post_ping(shard_id)
docker build -t greenbigfrog/shardmaster-example -f example/Dockerfile .
docker build -t greenbigfrog/shardmaster .
- Fork it (https://github.com/greenbigfrog/shardmaster/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Jonathan B. - creator and maintainer