#打包程序名称
APP_NAME="iot_service"
#线上路径
SERVER_PATH="/opt/lc/iot_svr/"

BINARY="build/${APP_NAME}"
VERSION=1.0.0
export GOARCH=amd64
export GOOS=linux
SHELL := D:\Programs\Git\bin\bash.exe

clear:
	@$(RM) ${BINARY}

build:
	@go build  -o ${BINARY} ./

#发布测试环境
push-test:clear build
	@$(call pushServer,"110.40.223.170")

#发布到正式环境
push-pro:clear build
	#@$(call pushServer,"106.52.134.22")

.PHONY: build push-test push-pro

define pushServer
	ssh root@$(1) "service  go-${APP_NAME} stop;"
    scp -r build/* root@$(1):${SERVER_PATH}
    ssh root@$(1) "chmod +x ${SERVER_PATH}${APP_NAME};service  go-${APP_NAME} start;sleep 3;service  go-${APP_NAME} status"
endef