Skip to content

Commit 2b3b451

Browse files
committed
Simplify local cluster script
1 parent 4245ec5 commit 2b3b451

File tree

23 files changed

+31
-13
lines changed

23 files changed

+31
-13
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ With a [Rust compiler](https://www.rust-lang.org/tools/install) installed, a loc
3434
cluster can be started on `localhost` ports `9601` to `9605`:
3535

3636
```
37-
$ (cd clusters/local && ./run.sh)
37+
$ ./cluster/run.sh
3838
```
3939

4040
A command-line client can be built and used with the node on `localhost` port `9605`:

Diff for: cluster/run.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This script builds and runs a 5-node toyDB cluster listening on ports
4+
# 9601-9605. Config and data is stored under the toydb* directories.
5+
# To connect a toysql client to node 5 on port 9605, run:
6+
#
7+
# cargo run --release --bin toysql
8+
9+
set -euo pipefail
10+
11+
# Change into the script directory.
12+
cd "$(dirname $0)"
13+
14+
# Build toyDB and toySQL using release optimizations.
15+
cargo build --release --bin toydb
16+
cargo build --release --bin toysql
17+
18+
# Start nodes 1-5 in the background, prefixing their output with the node ID.
19+
echo "Starting 5 nodes on ports 9601-9605. To connect to node 5, run:"
20+
echo "cargo run --release --bin toysql"
21+
echo ""
22+
23+
for ID in 1 2 3 4 5; do
24+
(cargo run -q --release -- -c toydb$ID/toydb.yaml 2>&1 | sed -e "s/\\(.*\\)/toydb$ID \\1/g") &
25+
done
26+
27+
# Wait for the background processes to exit. Kill all toyDB processes when the
28+
# script exits (e.g. via Ctrl-C).
29+
trap 'kill $(jobs -p)' EXIT
30+
wait < <(jobs -p)
File renamed without changes.

Diff for: cluster/toydb1/data/log

164 Bytes
Binary file not shown.

Diff for: cluster/toydb1/data/state

100 Bytes
Binary file not shown.
File renamed without changes.
File renamed without changes.

Diff for: cluster/toydb2/data/log

164 Bytes
Binary file not shown.

Diff for: cluster/toydb2/data/state

100 Bytes
Binary file not shown.
File renamed without changes.
File renamed without changes.

Diff for: cluster/toydb3/data/log

164 Bytes
Binary file not shown.

Diff for: cluster/toydb3/data/state

100 Bytes
Binary file not shown.
File renamed without changes.
File renamed without changes.

Diff for: cluster/toydb4/data/log

164 Bytes
Binary file not shown.

Diff for: cluster/toydb4/data/state

100 Bytes
Binary file not shown.
File renamed without changes.
File renamed without changes.

Diff for: cluster/toydb5/data/log

153 Bytes
Binary file not shown.

Diff for: cluster/toydb5/data/state

100 Bytes
Binary file not shown.
File renamed without changes.

Diff for: clusters/local/run.sh

-12
This file was deleted.

0 commit comments

Comments
 (0)