forked from tinode/chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
25 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# Start test cluster on one host. This is provided just as an example. | ||
# Start/stop test cluster on localhost. This is NOT a production script. Use it for reference only. | ||
|
||
./server -config=./tinode.conf -cluster_self=one -listen=:6060 & | ||
./server -config=./tinode.conf -cluster_self=two -listen=:6061 & | ||
./server -config=./tinode.conf -cluster_self=three -listen=:6062 & | ||
# Names of cluster nodes | ||
node_names=( one two three ) | ||
# Port where the first node will listen for client connections over http | ||
base_http_port=6080 | ||
# Port where the first node will listen for gRPC connections. | ||
base_grpc_port=6090 | ||
|
||
case "$1" in | ||
start) | ||
echo 'Running cluster on localhost, ports 6080-6082' | ||
|
||
http_port=$base_http_port | ||
grpc_port=$base_grpc_port | ||
for node_name in "${node_names[@]}" | ||
do | ||
./server -config=./tinode.conf -cluster_self=$node_name -listen=:${http_port} -grpc_listen=:${grpc_port} & | ||
# /var/tmp/ does not requre root access | ||
echo $!> "/var/tmp/tinode-${node_name}.pid" | ||
http_port=$((http_port+1)) | ||
grpc_port=$((grpc_port+1)) | ||
done | ||
;; | ||
stop) | ||
echo 'Stopping cluster' | ||
|
||
for node_name in "${node_names[@]}" | ||
do | ||
kill `cat /var/tmp/tinode-${node_name}.pid` | ||
rm "/var/tmp/tinode-${node_name}.pid" | ||
done | ||
;; | ||
*) | ||
echo $"Usage: $0 {start|stop}" | ||
esac |
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