Skip to content

Commit

Permalink
Support better chain name (#57)
Browse files Browse the repository at this point in the history
* Support better chain name

* wait 15s for sworker

* fix command error

* check docker run success

* split archive
  • Loading branch information
LowEntropyBody authored Sep 1, 2020
1 parent 28ba3d4 commit c39ffac
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
27 changes: 15 additions & 12 deletions generator/config-gen/chain-config.gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,34 @@ async function genChainConfig(config, outputCfg) {

async function genChainComposeConfig(config) {
let args = [
`--base-path ${config.chain.base_path}`,
'--chain maxwell',
`--port ${config.chain.port}`,
`--name ${config.chain.name}`,
`--rpc-port ${config.chain.rpc_port}`,
`--ws-port ${config.chain.ws_port}`,
'./crust',
'--base-path',
`${config.chain.base_path}`,
'--chain',
'maxwell',
'--port',
`${config.chain.port}`,
'--name',
`${config.chain.name}`,
'--rpc-port',
`${config.chain.rpc_port}`,
'--ws-port',
`${config.chain.ws_port}`,
]

if (config.node.chain == "authority") {
args.push('--validator', '--pruning archive')
args.push('--validator', '--pruning', 'archive')
} else if (config.node.chain == "light") {
args.push('--light')
}

args=args.join(' ')

return {
image: 'crustio/crust:latest',
network_mode: 'host',
volumes: [
`${config.chain.base_path}:${config.chain.base_path}`
],
environment: {
ARGS: args,
},
command: args,
}
}

Expand Down
2 changes: 1 addition & 1 deletion generator/schema/chain.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const bluebird = require('bluebird')

const chainSchema = Joi.object({
base_path: Joi.string().required(),
name: Joi.string().regex(/^[0-9a-zA-Z_]+$/).required(),
name: Joi.string().required(),
port: Joi.number().port().default(30333),
rpc_port: Joi.number().port().default(9933),
ws_port: Joi.number().port().default(9944),
Expand Down
12 changes: 11 additions & 1 deletion scripts/crust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@ start()
fi

docker-compose -f $builddir/docker-compose.yaml up -d crust
sleep 20
if [ $? -ne 0 ]; then
echo "Start crust chain failed"
exit 1
fi

sleep 15

docker-compose -f $builddir/docker-compose.yaml up -d
if [ $? -ne 0 ]; then
echo "Start other modules failed"
exit 1
fi
}

stop()
Expand Down

0 comments on commit c39ffac

Please sign in to comment.