Skip to content

Commit

Permalink
[bootstrap] fix: add stop_grace_period to server and broker container…
Browse files Browse the repository at this point in the history
…s (#400)

* [bootstrap] fix: add stop_grace_period to server and broker containers
  • Loading branch information
cryptoBeliever authored May 22, 2023
1 parent 128f9be commit b1d907f
Show file tree
Hide file tree
Showing 24 changed files with 92 additions and 18 deletions.
2 changes: 1 addition & 1 deletion presets/mainnet/network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ minVotingKeyLifetime: 112
maxVotingKeyLifetime: 360
votingKeyDesiredLifetime: 360
votingKeyDesiredFutureLifetime: 60
lastKnownNetworkEpoch: 1513
lastKnownNetworkEpoch: 1573
stepDuration: 5m
maxBlockFutureTime: 300ms
maxAccountRestrictionValues: 100
Expand Down
5 changes: 5 additions & 0 deletions presets/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ maxWriterThreads: 8
maxDropBatchSize: 10
writeTimeout: 10m

# stop grace periods
nodeStopGracePeriod: 300s
brokerStopGracePeriod: 20s

#Peer List configuration
peersP2PListLimit: 10
peersApiListLimit: 10
Expand Down Expand Up @@ -232,3 +236,4 @@ treasuryReissuanceTransactionSignatures_has_items: false
corruptAggregateTransactionHashes_has_items: false
treasuryReissuanceTransactionSignatures: []
corruptAggregateTransactionHashes: []

2 changes: 1 addition & 1 deletion presets/testnet/network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ importanceGrouping: 180
votingSetGrouping: 720
votingKeyDesiredLifetime: 720
votingKeyDesiredFutureLifetime: 120
lastKnownNetworkEpoch: 520
lastKnownNetworkEpoch: 636
minVotingKeyLifetime: 28
maxVotingKeyLifetime: 720
stepDuration: 4m
Expand Down
3 changes: 3 additions & 0 deletions src/model/ConfigPreset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface DockerServicePreset {
excludeDockerService?: boolean;
compose?: DockerComposeService;
dockerComposeDebugMode?: boolean;
stopGracePeriod?: string;
}

export interface CurrencyDistribution {
Expand Down Expand Up @@ -254,6 +255,8 @@ export interface NodeConfigPreset {
caCertificateExpirationInDays: number;
nodeCertificateExpirationInDays: number;
certificateExpirationWarningInDays: number;
nodeStopGracePeriod: string;
brokerStopGracePeriod: string;
}

export interface NodePreset extends DockerServicePreset, Partial<NodeConfigPreset> {
Expand Down
1 change: 1 addition & 0 deletions src/model/DockerCompose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface DockerComposeService {
hostname?: string;
environment?: Record<string, string>;
stop_signal?: string;
stop_grace_period?: string;
volumes?: string[];
ports?: string[];
depends_on?: string[];
Expand Down
40 changes: 27 additions & 13 deletions src/service/ComposeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ export class ComposeService {
service.hostname = servicePreset.host;
service.networks!.default.aliases = [servicePreset.host];
}
if (servicePreset.stopGracePeriod) {
service.stop_grace_period = servicePreset.stopGracePeriod;
}
if (servicePreset.ipv4_address) {
service.networks!.default.ipv4_address = servicePreset.ipv4_address;
}
Expand Down Expand Up @@ -194,19 +197,29 @@ export class ComposeService {
vol(`../${targetNodesFolder}/${n.name}`, nodeWorkingDirectory, false),
vol(`./server`, nodeCommandsDirectory, true),
];
const nodeService = await resolveService(n, {
user: serverDebugMode === debugFlag ? undefined : user, // if debug on, run as root
container_name: n.name,
image: presetData.symbolServerImage,
command: serverCommand,
stop_signal: 'SIGINT',
working_dir: nodeWorkingDirectory,
restart: restart,
ports: resolvePorts(portConfigurations),
volumes: volumes,
depends_on: serverDependsOn,
...this.resolveDebugOptions(presetData.dockerComposeDebugMode, n.dockerComposeDebugMode),
});
const nodeService = await resolveService(
{
ipv4_address: n.ipv4_address,
openPort: n.openPort,
excludeDockerService: n.excludeDockerService,
host: n.host,
compose: n.compose,
stopGracePeriod: n.nodeStopGracePeriod || presetData.nodeStopGracePeriod,
},
{
user: serverDebugMode === debugFlag ? undefined : user, // if debug on, run as root
container_name: n.name,
image: presetData.symbolServerImage,
command: serverCommand,
stop_signal: 'SIGINT',
working_dir: nodeWorkingDirectory,
restart: restart,
ports: resolvePorts(portConfigurations),
volumes: volumes,
depends_on: serverDependsOn,
...this.resolveDebugOptions(presetData.dockerComposeDebugMode, n.dockerComposeDebugMode),
},
);

services.push(nodeService);
if (n.brokerName) {
Expand All @@ -218,6 +231,7 @@ export class ComposeService {
excludeDockerService: n.brokerExcludeDockerService,
host: n.brokerHost,
compose: n.brokerCompose,
stopGracePeriod: n.brokerStopGracePeriod || presetData.brokerStopGracePeriod,
},
{
user: brokerDebugMode === debugFlag ? undefined : user, // if debug on, run as root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker peer-node-0 NORMAL false
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -50,6 +51,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker peer-node-1 NORMAL false
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -74,6 +76,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker api-node-0 NORMAL true
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
volumes:
Expand All @@ -96,6 +99,7 @@ services:
ports:
- '8002:7902'
stop_signal: SIGINT
stop_grace_period: 20s
restart: 'on-failure:2'
volumes:
- '../nodes/api-node-0:/symbol-workdir:rw'
Expand Down
4 changes: 4 additions & 0 deletions test/composes/expected-docker-compose-bootstrap-custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker peer-node-0 DEBUG false
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -41,6 +42,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker peer-node-1 DEBUG false
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -63,6 +65,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker api-node-0 DEBUG true
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
volumes:
Expand All @@ -89,6 +92,7 @@ services:
ports:
- '8002:7902'
stop_signal: SIGINT
stop_grace_period: 20s
restart: 'on-failure:2'
volumes:
- '../nodes/api-node-0:/symbol-workdir:rw'
Expand Down
2 changes: 2 additions & 0 deletions test/composes/expected-docker-compose-bootstrap-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker node DEBUG true
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -43,6 +44,7 @@ services:
working_dir: /symbol-workdir
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data broker server broker DEBUG
stop_signal: SIGINT
stop_grace_period: 20s
restart: 'on-failure:2'
volumes:
- '../nodes/node:/symbol-workdir:rw'
Expand Down
2 changes: 2 additions & 0 deletions test/composes/expected-docker-compose-bootstrap-dual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker node NORMAL true
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -35,6 +36,7 @@ services:
working_dir: /symbol-workdir
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data broker server broker NORMAL
stop_signal: SIGINT
stop_grace_period: 20s
restart: 'on-failure:2'
volumes:
- '../nodes/node:/symbol-workdir:rw'
Expand Down
11 changes: 11 additions & 0 deletions test/composes/expected-docker-compose-bootstrap-repeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker peer-node-0 NORMAL false
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -80,6 +81,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker peer-node-1 NORMAL false
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -98,6 +100,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker peer-node-2 NORMAL false
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -116,6 +119,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker api-node-0 NORMAL true
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
volumes:
Expand All @@ -135,6 +139,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker api-node-1 NORMAL true
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
volumes:
Expand All @@ -154,6 +159,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker api-node-2 NORMAL true
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
volumes:
Expand All @@ -173,6 +179,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker api-node-3 NORMAL true
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
volumes:
Expand All @@ -195,6 +202,7 @@ services:
ports:
- '8002:7902'
stop_signal: SIGINT
stop_grace_period: 20s
restart: 'on-failure:2'
volumes:
- '../nodes/api-node-0:/symbol-workdir:rw'
Expand All @@ -210,6 +218,7 @@ services:
ports:
- '8003:7902'
stop_signal: SIGINT
stop_grace_period: 20s
restart: 'on-failure:2'
volumes:
- '../nodes/api-node-1:/symbol-workdir:rw'
Expand All @@ -225,6 +234,7 @@ services:
ports:
- '8004:7902'
stop_signal: SIGINT
stop_grace_period: 20s
restart: 'on-failure:2'
volumes:
- '../nodes/api-node-2:/symbol-workdir:rw'
Expand All @@ -240,6 +250,7 @@ services:
ports:
- '8005:7902'
stop_signal: SIGINT
stop_grace_period: 20s
restart: 'on-failure:2'
volumes:
- '../nodes/api-node-3:/symbol-workdir:rw'
Expand Down
4 changes: 4 additions & 0 deletions test/composes/expected-docker-compose-bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker peer-node-0 NORMAL false
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -38,6 +39,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker peer-node-1 NORMAL false
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -56,6 +58,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker api-node-0 NORMAL true
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
volumes:
Expand All @@ -78,6 +81,7 @@ services:
ports:
- '8002:7902'
stop_signal: SIGINT
stop_grace_period: 20s
restart: 'on-failure:2'
volumes:
- '../nodes/api-node-0:/symbol-workdir:rw'
Expand Down
2 changes: 2 additions & 0 deletions test/composes/expected-mainnet-api-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker node NORMAL true
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -35,6 +36,7 @@ services:
working_dir: /symbol-workdir
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data broker server broker NORMAL
stop_signal: SIGINT
stop_grace_period: 20s
restart: 'on-failure:2'
volumes:
- '../nodes/node:/symbol-workdir:rw'
Expand Down
4 changes: 4 additions & 0 deletions test/composes/expected-mainnet-custom-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
image: 'mongo:5.0.15'
command: mongod --dbpath=/dbdata --bind_ip=db --wiredTigerCacheSizeGB 2
stop_signal: SIGINT
stop_grace_period: 25s
working_dir: /docker-entrypoint-initdb.d
volumes:
- './mongo:/docker-entrypoint-initdb.d:ro'
Expand All @@ -26,6 +27,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker node NORMAL true
stop_signal: SIGINT
stop_grace_period: 350s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand Down Expand Up @@ -56,6 +58,7 @@ services:
working_dir: /symbol-workdir
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data broker server broker NORMAL
stop_signal: SIGINT
stop_grace_period: 30s
restart: 'on-failure:2'
volumes:
- '../nodes/node:/symbol-workdir:rw'
Expand All @@ -78,6 +81,7 @@ services:
image: 'symbolplatform/symbol-rest:2.4.3'
command: npm start --prefix /app /symbol-workdir/rest.json
stop_signal: SIGINT
stop_grace_period: 15s
working_dir: /symbol-workdir
ports:
- '3000:3000'
Expand Down
2 changes: 2 additions & 0 deletions test/composes/expected-mainnet-dual-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
image: 'symbolplatform/symbol-server:gcc-1.0.3.6'
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data server broker node NORMAL true
stop_signal: SIGINT
stop_grace_period: 300s
working_dir: /symbol-workdir
restart: 'on-failure:2'
ports:
Expand All @@ -35,6 +36,7 @@ services:
working_dir: /symbol-workdir
command: /bin/bash /symbol-commands/start.sh /usr/catapult ./data broker server broker NORMAL
stop_signal: SIGINT
stop_grace_period: 20s
restart: 'on-failure:2'
volumes:
- '../nodes/node:/symbol-workdir:rw'
Expand Down
Loading

0 comments on commit b1d907f

Please sign in to comment.