Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better check port and readme #63

Merged
merged 1 commit into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,25 @@ sudo vim /opt/crust/crust-node/config.yaml
```

### Run crust service and karst service
Please make sure the following ports are not occupied before starting:
- 30333 9933 9944 (for crust chain)
- 56666 (for crust API)
- 12222 (for crust sWorker)
- 17000 (for karst)

- Please make sure the following ports are not occupied before starting:
- 30333 9933 9944 (for crust chain)
- 56666 (for crust API)
- 12222 (for crust sWorker)
- 17000 (for karst)


```shell
sudo systemctl start karst # if you set karst 'enable' in config.yaml
sudo systemctl start crust
sudo systemctl start karst
```

### Stop crust service and karst service
- Need to stop crust first, then stop karst

```shell
sudo systemctl stop crust
sudo systemctl stop karst # if you set karst 'enable' in config.yaml
```

## License
Expand Down
24 changes: 22 additions & 2 deletions scripts/crust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ builddir=$basedir/build
start()
{
echo "Start"
check_port 30333 && check_port 9933 && check_port 9944 && check_port 56666 && check_port 12222 && check_port 17000

local res=0
check_port 30333
res=$(($?|$res))
check_port 9933
res=$(($?|$res))
check_port 9944
res=$(($?|$res))
if [ $res -ne 0 ]; then
exit 1
fi

$scriptdir/gen_config.sh
if [ $? -ne 0 ]; then
Expand All @@ -30,6 +40,16 @@ start()
fi

if [ -d "$builddir/sworker" ]; then
local res=0
check_port 56666
res=$(($?|$res))
check_port 12222
res=$(($?|$res))
if [ $res -ne 0 ]; then
docker-compose -f $builddir/docker-compose.yaml rm -fsv crust
exit 1
fi

docker-compose -f $builddir/docker-compose.yaml up -d crust-api
if [ $? -ne 0 ]; then
docker-compose -f $builddir/docker-compose.yaml rm -fsv crust
Expand Down Expand Up @@ -73,7 +93,7 @@ check_port() {
grep_port=`netstat -tlpn | grep "\b$port\b"`
if [ -n "$grep_port" ]; then
echo "Please make sure port $port is not occupied"
exit 1
return 1
fi
}

Expand Down
14 changes: 14 additions & 0 deletions scripts/karst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ builddir=$basedir/build
start()
{
echo "Start"
check_port 17000
if [ $? -ne 0 ]; then
exit 1
fi

$scriptdir/gen_config.sh
if [ $? -ne 0 ]; then
echo "Generate configuration files failed"
Expand Down Expand Up @@ -42,6 +47,15 @@ reload() {
stop
start
}

check_port() {
port=$1
grep_port=`netstat -tlpn | grep "\b$port\b"`
if [ -n "$grep_port" ]; then
echo "Please make sure port $port is not occupied"
return 1
fi
}

case "$1" in
start)
Expand Down