Skip to content

Commit

Permalink
Merge pull request #73 from zhangshen023/sample_start_up_scripts
Browse files Browse the repository at this point in the history
Sample startup scripts

Former-commit-id: 1010559
  • Loading branch information
cityiron authored Dec 20, 2020
2 parents 9648348 + 4886082 commit a5dedb0
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ mainPath := $(currentPath)$(proxyPath)
$(info $(mainPath))

targetName := dubbo-go-proxy

api-config-path:=${api-config}
ifeq ("",$(api-config-path))
api-config-path = configs/api_config.yaml
endif

config-path:=${config-path}
ifeq ("",$(config-path))
config-path = configs/conf.yaml
endif

os := $(shell go env GOOS)
$(info os is $(os))
ifeq (windows,$(os))
Expand All @@ -17,4 +28,4 @@ build:
cd $(mainPath) && go build -o $(targetName)

run: build
cp $(exe) $(currentPath) && ./dubbo-go-proxy start
cp $(exe) $(currentPath) && ./dubbo-go-proxy start -a $(api-config-path) -c $(config-path)
37 changes: 37 additions & 0 deletions docs/sample/dubbo_sample_startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
if [ "$1" != "skip_zookeeper" ]; then
zookeeper_container_id=$(docker ps | grep zookeeper | head -n 1 | awk '{print $1}')
if [ -n "$zookeeper_container_id" ]; then
echo "removing old zookeeper!"
docker kill "$zookeeper_container_id"
docker rm "$zookeeper_container_id"
fi
echo "starting zookeeper!"
docker run -dit --name zookeeper -p 2181:2181 zookeeper:3.4.14
echo "zookeeper stated!"
fi

go env -w GOPROXY=https://goproxy.cn,direct

echo "starting dubbogo provider!"
if [ -z "$CONF_PROVIDER_FILE_PATH" ]; then
export CONF_PROVIDER_FILE_PATH=../../sample/dubbogo/server/config/server.yml
fi
go build ../../sample/dubbogo/server/app/

provider_pid=$(ps -ef | grep ../../sample/dubbogo/server/app/ | grep -v 'grep' | awk '{print $2}')

if [ -n "$provider_pid" ]; then
echo "pid of old dubbogo provider is $provider_pid, kill it"
kill -9 "$provider_pid"
fi
nohup go run ../../sample/dubbogo/server/app/ >dubbgo_server.out &
sleep 10
echo "dubbogo provider started!"

## to start proxy

echo "starting proxy!"

cd ../../
make run config-path=sample/dubbogo/proxy/conf.yaml api-config-path=sample/dubbogo/proxy/api_config.yaml
37 changes: 37 additions & 0 deletions docs/sample/http_sample_startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
if [ "$1" != "skip_zookeeper" ]; then
zookeeper_container_id=$(docker ps | grep zookeeper | head -n 1 | awk '{print $1}')
if [ -n "$zookeeper_container_id" ]; then
echo "removing old zookeeper!"
docker kill "$zookeeper_container_id"
docker rm "$zookeeper_container_id"
fi
echo "starting zookeeper!"
docker run -dit --name zookeeper -p 2181:2181 zookeeper:3.4.14
echo "zookeeper stated!"
fi

go env -w GOPROXY=https://goproxy.cn,direct

echo "starting dubbogo provider!"
if [ -z "$CONF_PROVIDER_FILE_PATH" ]; then
export CONF_PROVIDER_FILE_PATH=../../sample/http/server/config/server.yml
fi
go build ../../sample/http/server/app/

provider_pid=$(ps -ef | grep ../../sample/http/server/app/ | grep -v 'grep' | awk '{print $2}')

if [ -n "$provider_pid" ]; then
echo "pid of old dubbogo provider is $provider_pid, kill it"
kill -9 "$provider_pid"
fi
nohup go run ../../sample/http/server/app/ >http_server.out &
sleep 10
echo "dubbogo provider started!"

## to start proxy

echo "starting proxy!"

cd ../../
make run config-path=sample/http/proxy/conf.yaml api-config-path=sample/http/proxy/api_config.yaml

0 comments on commit a5dedb0

Please sign in to comment.