Makefile 705 B

1234567891011121314151617181920212223242526272829303132
  1. #打包程序名称
  2. APP_NAME="iot_service"
  3. #线上路径
  4. SERVER_PATH="/opt/lc/iot_svr/"
  5. BINARY="build/${APP_NAME}"
  6. VERSION=1.0.0
  7. export GOARCH=amd64
  8. export GOOS=linux
  9. SHELL := D:\Programs\Git\bin\bash.exe
  10. clear:
  11. @$(RM) ${BINARY}
  12. build:
  13. @go build -o ${BINARY} ./
  14. #发布测试环境
  15. push-test:clear build
  16. @$(call pushServer,"110.40.223.170")
  17. #发布到正式环境
  18. push-pro:clear build
  19. #@$(call pushServer,"106.52.134.22")
  20. .PHONY: build push-test push-pro
  21. define pushServer
  22. ssh root@$(1) "service go-${APP_NAME} stop;"
  23. scp -r build/* root@$(1):${SERVER_PATH}
  24. ssh root@$(1) "chmod +x ${SERVER_PATH}${APP_NAME};service go-${APP_NAME} start;sleep 3;service go-${APP_NAME} status"
  25. endef