Ver Fonte

发布脚本修复

sixian há 2 anos atrás
pai
commit
986c2b46a2
1 ficheiros alterados com 18 adições e 7 exclusões
  1. 18 7
      Makefile

+ 18 - 7
Makefile

@@ -1,4 +1,9 @@
-BINARY="build/iot_service"
+#打包程序名称
+APP_NAME="iot_service"
+#线上路径
+SERVER_PATH="/opt/lc/iot_svr/"
+
+BINARY="build/${APP_NAME}"
 VERSION=1.0.0
 export GOARCH=amd64
 export GOOS=linux
@@ -10,12 +15,18 @@ clear:
 build:
 	@go build  -o ${BINARY} ./
 
+#发布测试环境
 push-test:clear build
-	@$(push_test)
-.PHONY: build push-test
+	@$(call pushServer,"110.40.223.170")
+
+#发布到正式环境
+push-pro:clear build
+	#@$(call pushServer,"106.52.134.22")
+
+.PHONY: build push-test push-pro
 
-define push_test
-	ssh root@110.40.223.170 "service  go-iot_service stop;/usr/bin/rm -rf /opt/lc/iot_svr/iot_service"
-    scp -r build/* root@110.40.223.170:/opt/lc/iot_svr/
-    ssh root@110.40.223.170 "chmod +x /opt/lc/iot_svr/iot_service;service  go-iot_service start;sleep 3;service  go-iot_service status"
+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