-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathstart-localnet.ts
More file actions
83 lines (73 loc) · 2.43 KB
/
start-localnet.ts
File metadata and controls
83 lines (73 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { execFileSync } from 'child_process'
import fs from 'fs'
import path from 'path'
import { getRepoRoot, getNetworkArg, SUPPORTED_VERSIONS } from './lib/utils.js'
const args = process.argv.slice(2)
const command = args[0]
const rootDir = getRepoRoot()
const LOCALNET_DIR = path.join(rootDir, '.localnet/docker-compose/localnet')
const GENERATED_COMPOSE_OVERRIDE = path.join(
rootDir,
'.temp/start-localnet.override.yaml'
)
const CANTON_MAX_COMMANDS_IN_FLIGHT = 256
function ensureComposeOverride() {
fs.mkdirSync(path.dirname(GENERATED_COMPOSE_OVERRIDE), { recursive: true })
fs.writeFileSync(
GENERATED_COMPOSE_OVERRIDE,
[
'services:',
' canton:',
' environment:',
' ADDITIONAL_CONFIG_MAX_COMMANDS_IN_FLIGHT: |-',
` canton.participants.app-provider.ledger-api.command-service.max-commands-in-flight = ${CANTON_MAX_COMMANDS_IN_FLIGHT}`,
` canton.participants.app-user.ledger-api.command-service.max-commands-in-flight = ${CANTON_MAX_COMMANDS_IN_FLIGHT}`,
` canton.participants.sv.ledger-api.command-service.max-commands-in-flight = ${CANTON_MAX_COMMANDS_IN_FLIGHT}`,
'',
].join('\n'),
'utf8'
)
}
const composeBase = [
'docker',
'compose',
'--env-file',
`${LOCALNET_DIR}/compose.env`,
'--env-file',
`${LOCALNET_DIR}/env/common.env`,
'-f',
`${LOCALNET_DIR}/compose.yaml`,
'-f',
`${LOCALNET_DIR}/resource-constraints.yaml`,
'-f',
GENERATED_COMPOSE_OVERRIDE,
'--profile',
'sv',
'--profile',
'app-provider',
'--profile',
'app-user',
'--profile',
'multi-sync',
]
const network = getNetworkArg()
const spliceVersion = SUPPORTED_VERSIONS[network].splice.version
// Set IMAGE_TAG env variable to SPLICE_VERSION
const env = { ...process.env, IMAGE_TAG: spliceVersion }
ensureComposeOverride()
if (command === 'start') {
execFileSync(composeBase[0], [...composeBase.slice(1), 'up', '-d'], {
stdio: 'inherit',
env,
})
} else if (command === 'stop') {
execFileSync(composeBase[0], [...composeBase.slice(1), 'down', '-v'], {
stdio: 'inherit',
env,
})
} else {
console.error('Usage: start-localnet.ts <start|stop>')
process.exit(1)
}