Skip to content

Commit

Permalink
#230 Add cyberd rest light-client to docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
arturalbov committed Feb 4, 2019
1 parent 3998c9f commit 342184a
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 7 deletions.
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ jobs:
command: |
docker build -t build/cyberd .
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker tag build/cyberd cyberd/cyberd:$CIRCLE_TAG
docker push cyberd/cyberd:$CIRCLE_TAG
docker tag build/cyberd cyberd/cyberd:euler-$CIRCLE_TAG
docker push cyberd/cyberd:euler-$CIRCLE_TAG
docker tag build/cyberd cyberd/cyberd:euler-1
docker push cyberd/cyberd:euler-1
release_cyberdcli_binaries:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ RUN chmod +x /entrypoint.sh

# Start
###############################################################################
EXPOSE 26656 26657 26660
EXPOSE 26656 26657 1317
ENTRYPOINT ["/entrypoint.sh"]
CMD ["./start_script.sh"]
19 changes: 19 additions & 0 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/lcd"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -25,6 +26,12 @@ import (
"github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/libs/cli"
"os"

auth "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
bank "github.com/cosmos/cosmos-sdk/x/bank/client/rest"
gov "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
slashing "github.com/cosmos/cosmos-sdk/x/slashing/client/rest"
staking "github.com/cosmos/cosmos-sdk/x/staking/client/rest"
)

func main() {
Expand Down Expand Up @@ -58,6 +65,8 @@ func main() {
txCmd(cdc, mc),
keys.Commands(),
client.LineBreak,
lcd.ServeCommand(cdc, registerRoutes),
client.LineBreak,
version.VersionCmd,
client.NewCompletionCmd(cyberdcli, true),
)
Expand All @@ -75,6 +84,16 @@ func main() {
}
}

func registerRoutes(rs *lcd.RestServer) {
rpc.RegisterRoutes(rs.CliCtx, rs.Mux)
tx.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc)
auth.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, at.StoreKey)
bank.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
staking.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
slashing.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
gov.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc)
}

func queryCmd(cdc *amino.Codec, mc []sdk.ModuleClients) *cobra.Command {
queryCmd := &cobra.Command{
Use: "query",
Expand Down
4 changes: 2 additions & 2 deletions docs/run_validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ mkdir /cyberd
Run daemon with mounted volumes on created during previous step folder.
```bash
docker run -d --name=cyberd --restart always --runtime=nvidia \
-p 26656:26656 -p 26657:26657 -p 26660:26660 \
-p 26656:26656 -p 26657:26657 -p 26660:26660 -p 1317:1317 \
-v /cyberd/daemon:/root/.cyberd \
-v /cyberd/cli:/root/.cyberdcli \
cyberd/cyberd:<testnet_chain_id>
Expand All @@ -86,7 +86,7 @@ docker rm cyberd
docker pull cyberd/cyberd:<testnet_chain_id>

docker run -d --name=cyberd --restart always --runtime=nvidia \
-p 26656:26656 -p 26657:26657 -p 26660:26660 \
-p 26656:26656 -p 26657:26657 -p 26660:26660 -p 1317:1317 \
-v /cyberd/daemon:/root/.cyberd \
-v /cyberd/cli:/root/.cyberdcli \
cyberd/cyberd:<testnet_chain_id>
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ require (
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e // indirect
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273 // indirect
github.com/rakyll/statik v0.1.5 // indirect
github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165 // indirect
github.com/rs/cors v1.6.0 // indirect
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e h1:n/3MEhJQjQxrO
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273 h1:agujYaXJSxSo18YNX3jzl+4G6Bstwt+kqv47GS12uL0=
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/rakyll/statik v0.1.5/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs=
github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165 h1:nkcn14uNmFEuGCb2mBZbBb24RdNRL08b/wb+xBOYpuk=
github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rs/cors v1.6.0 h1:G9tHG9lebljV9mfp9SNPDL36nCDxmo3zTlAf1YgvzmI=
Expand Down
35 changes: 33 additions & 2 deletions start_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,36 @@ else
COMPUTE_GPU="${COMPUTE_RANK_ON_GPU}"
fi

echo ${COMPUTE_GPU}
cyberd start --compute-rank-on-gpu=${COMPUTE_GPU}
# Start the first process
cyberd start --compute-rank-on-gpu=${COMPUTE_GPU} . &
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start cyberd: $status"
exit $status
fi

# Start the second process
cyberdcli rest-server --cors=* --trust-node --chain-id=euler-1 --laddr=tcp://0.0.0.0:1317 --indent --insecure . &
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start cyberd light-client: $status"
exit $status
fi

# Naive check runs checks once a minute to see if either of the processes exited.
# This illustrates part of the heavy lifting you need to do if you want to run
# more than one service in a container. The container exits with an error
# if it detects that either of the processes has exited.
# Otherwise it loops forever, waking up every 60 seconds
while sleep 60; do
ps aux |grep cyberd |grep -q -v grep
PROCESS_1_STATUS=$?
ps aux |grep cyberdcli |grep -q -v grep
PROCESS_2_STATUS=$?
# If the greps above find anything, they exit with 0 status
# If they are not both 0, then something is wrong
if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then
echo "One of the processes has already exited."
exit 1
fi
done

0 comments on commit 342184a

Please sign in to comment.