Skip to content

Commit

Permalink
Easier support for multiple instances locally (cadence-workflow#6289)
Browse files Browse the repository at this point in the history
* Make ports configurable, so we can start several instances of the same service.

We keep the old defaults, so if nothing is specified everything works as before

* Added script that starts several instances of the services, mainly for illustrative purposes, but could be useful to quickly start.

* The services are now killed on ctrl-c
  • Loading branch information
jakobht authored Sep 20, 2024
1 parent 811ffe7 commit c8abc2a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
22 changes: 11 additions & 11 deletions config/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,53 +27,53 @@ ringpop:
services:
frontend:
rpc:
port: 7933
grpcPort: 7833
port: ${FRONTEND_PORT:7933}
grpcPort: ${FRONTEND_PORT_GRPC:7833}
bindOnLocalHost: true
grpcMaxMsgSize: 33554432
metrics:
statsd:
hostPort: "127.0.0.1:8125"
prefix: "cadence"
pprof:
port: 7936
port: ${FRONTEND_PORT_PPROF:7936}

matching:
rpc:
port: 7935
grpcPort: 7835
port: ${MATCHING_PORT:7935}
grpcPort: ${MATCHING_PORT_GRPC:7835}
bindOnLocalHost: true
grpcMaxMsgSize: 33554432
metrics:
statsd:
hostPort: "127.0.0.1:8125"
prefix: "cadence"
pprof:
port: 7938
port: ${MATCHING_PORT_PPROF:7938}

history:
rpc:
port: 7934
grpcPort: 7834
port: ${HISTORY_PORT:7934}
grpcPort: ${HISTORY_PORT_GRPC:7834}
bindOnLocalHost: true
grpcMaxMsgSize: 33554432
metrics:
statsd:
hostPort: "127.0.0.1:8125"
prefix: "cadence"
pprof:
port: 7937
port: ${HISTORY_PORT_PPROF:7937}

worker:
rpc:
port: 7939
port: ${WORKER_PORT:7939}
bindOnLocalHost: true
metrics:
statsd:
hostPort: "127.0.0.1:8125"
prefix: "cadence"
pprof:
port: 7940
port: ${WORKER_PORT_PPROF:7940}

clusterGroupMetadata:
failoverVersionIncrement: 10
Expand Down
36 changes: 36 additions & 0 deletions scripts/run_several_instances.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# This script can be used to run several instances of the different cadence services (matching, history, frontend, etc)
#

set -eo pipefail

ctrl_c() {
echo "Killing all the services"
pkill -9 -P $$
}

trap ctrl_c SIGINT

# Start the services used in ringpop discovery on the default ports
./cadence-server start &

# Start two more instances of the frontend service on different ports
FRONTEND_PORT=10001 FRONTEND_PORT_GRPC=10101 FRONTEND_PORT_PPROF=10201 \
./cadence-server --env development start --services frontend &
FRONTEND_PORT=10002 FRONTEND_PORT_GRPC=10102 FRONTEND_PORT_PPROF=10202 \
./cadence-server --env development start --services frontend &

# Start two more instances of the matching service on different ports
MATCHING_PORT=11001 MATCHING_PORT_GRPC=11101 MATCHING_PORT_PPROF=11201 \
./cadence-server --env development start --services matching &
MATCHING_PORT=11002 MATCHING_PORT_GRPC=11102 MATCHING_PORT_PPROF=11202 \
./cadence-server --env development start --services matching &

# Start two more instances of the history service on different ports
HISTORY_PORT=12001 HISTORY_PORT_GRPC=12101 HISTORY_PORT_PPROF=12201 \
./cadence-server --env development start --services history &
HISTORY_PORT=12002 HISTORY_PORT_GRPC=12102 HISTORY_PORT_PPROF=12202 \
./cadence-server --env development start --services history &

wait

0 comments on commit c8abc2a

Please sign in to comment.