From f0d7422ce5692b6fc3bf411d1ac040b1c0bc2e28 Mon Sep 17 00:00:00 2001 From: Bidaya0 Date: Mon, 6 Dec 2021 14:27:20 +0800 Subject: [PATCH 1/6] Update entrypoint.sh --- docker/entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index b3667c8..bdbdb14 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -4,6 +4,8 @@ sleep 2 echo $1 +rm /tmp/dongtai-engine.pid || true + if [ -z $1 ]; then echo '启动Celery Worker服务' celery -A lingzhi_engine worker -l info -E --pidfile=/tmp/dongtai-engine.pid From 2a006dbab3066117e41000136a6dbc36aa1828b8 Mon Sep 17 00:00:00 2001 From: "xianzelin@huoxian.cn" Date: Wed, 19 Jan 2022 14:21:04 +0800 Subject: [PATCH 2/6] merge main --- docker/entrypoint.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 6e20527..59ebbf7 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -4,8 +4,6 @@ sleep 2 echo $1 -rm /tmp/dongtai-engine.pid || true - if [ -z $1 ]; then echo '启动Celery Worker服务' celery -A lingzhi_engine worker -l info -E --pidfile= From c24bffb60b5309fa9d5e77e08e769a0f98cd2be3 Mon Sep 17 00:00:00 2001 From: "xianzelin@huoxian.cn" Date: Sat, 22 Jan 2022 15:45:07 +0800 Subject: [PATCH 3/6] add version register sql in actions --- .github/workflows/deploy_test.yml | 5 ++++ .github/workflows/release_engine.yml | 3 +++ docker/entrypoint.sh | 1 + docker/version.sql | 1 + docker/version.sql.example | 3 +++ docker/version_update.py | 36 ++++++++++++++++++++++++++++ 6 files changed, 49 insertions(+) create mode 100644 docker/version.sql create mode 100644 docker/version.sql.example create mode 100644 docker/version_update.py diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml index e1c2a21..54a54b1 100644 --- a/.github/workflows/deploy_test.yml +++ b/.github/workflows/deploy_test.yml @@ -96,6 +96,11 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Generate version file + run: | + echo "REPLACE INTO project_version_control (version, component_name, component_version_hash) VALUES('${{ github.run_number }}.0.0', '${{ github.event.repository.name }}', '${GITHUB_SHA}');" >> ./docker/version.sql + echo "REPLACE INTO project_version_control (version, component_name) VALUES('${{ github.run_number }}.0.0', 'DongTai');" >> ./docker/version.sql + - name: Login to DockerHub uses: docker/login-action@v1 with: diff --git a/.github/workflows/release_engine.yml b/.github/workflows/release_engine.yml index 92a6aaf..0d4480e 100644 --- a/.github/workflows/release_engine.yml +++ b/.github/workflows/release_engine.yml @@ -57,6 +57,9 @@ jobs: cd ${{ github.workspace }} && \ echo "${{ github.event.repository.name }},version,${{ steps.release.outputs.VERSION }}" >> version.txt && \ echo "${{ github.event.repository.name }},commit_hash,${GITHUB_SHA}" >> version.txt \ + MAIN_STREAM_VERSION=`echo ${{ steps.release.outputs.version }} | awk '{split($0,a,".");printf "%d.%d.x",a[1],a[2];}` + echo "REPLACE INTO project_version_control (version, component_name, component_version_hash) VALUES('${{ steps.release.outputs.version }}', '${{ github.event.repository.name }}', '${GITHUB_SHA}');" >> ./docker/version.sql + echo "REPLACE INTO project_version_control (version, component_name) VALUES('${{ MAIN_STREAM_VERSION }}', 'DongTai');" >> ./docker/version.sql - name: Upload version file to oss id: upload_version_file_to_oss diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 59ebbf7..26c9ff9 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,3 +1,4 @@ +python /opt/dongtai/engine/docker/version_update.py || true echo '启动uwsgi服务' nohup /usr/local/bin/uwsgi --ini /opt/dongtai/engine/conf/uwsgi.ini & sleep 2 diff --git a/docker/version.sql b/docker/version.sql new file mode 100644 index 0000000..12a37a4 --- /dev/null +++ b/docker/version.sql @@ -0,0 +1 @@ +CREATE TABLE IF NOT EXISTS `project_version_control` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键', `version` varchar(63) DEFAULT NULL COMMENT '版本号', `component_name` varchar(255) DEFAULT NULL COMMENT 'sql名', `component_version_hash` varchar(255) DEFAULT NULL COMMENT 'sql哈希值', `additional` text COMMENT '额外注释', `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `project_version_control_UN` (`component_name`) ) ENGINE = InnoDB CHARSET = utf8mb4; diff --git a/docker/version.sql.example b/docker/version.sql.example new file mode 100644 index 0000000..c4cd6b3 --- /dev/null +++ b/docker/version.sql.example @@ -0,0 +1,3 @@ +CREATE TABLE `project_version_control` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键', `version` varchar(63) DEFAULT NULL COMMENT '版本号', `component_name` varchar(255) DEFAULT NULL COMMENT 'sql名', `component_version_hash` varchar(255) DEFAULT NULL COMMENT 'sql哈希值', `additional` text COMMENT '额外注释', `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `project_version_control_UN` (`component_name`) ) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARSET = utf8mb4; +REPLACE INTO project_version_control (version, component_name, component_version_hash) VALUES('1.3.0', 'DongTai-webapi', '12313223121331232132'); +REPLACE INTO project_version_control (version, component_name, component_version_hash) VALUES('1.3.0', 'DongTai', '12313223121331232132'); diff --git a/docker/version_update.py b/docker/version_update.py new file mode 100644 index 0000000..341cc8f --- /dev/null +++ b/docker/version_update.py @@ -0,0 +1,36 @@ +###################################################################### +# @author : bidaya0 (bidaya0@$HOSTNAME) +# @file : version_update +# @created : 星期四 1月 20, 2022 15:42:27 CST +# +# @description : +###################################################################### + + +from configparser import ConfigParser +import os +import MySQLdb +import sys +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +config = ConfigParser() +status = config.read(os.path.join(BASE_DIR, 'conf/config.ini')) +if len(status) == 0: + print("config file not exist. stop running") + sys.exit(0) +DBCONFIG = { + 'user': config.get("mysql", 'user'), + 'db': config.get("mysql", 'name'), + 'passwd': config.get("mysql", 'password'), + 'host': config.get("mysql", 'host'), + 'port': int(config.get("mysql", 'port')), +} +db = MySQLdb.connect(**DBCONFIG, use_unicode=True, charset="utf8mb4") +cursor = db.cursor() +for line in open(os.path.join(BASE_DIR, 'docker/version.sql'), + encoding='utf-8'): + if not line.strip(): + continue + cursor.execute(line) +cursor.close() +db.commit() From 7ece36aecc6c00c8ecd53bc3ec21cb00fb978abd Mon Sep 17 00:00:00 2001 From: "xianzelin@huoxian.cn" Date: Sat, 22 Jan 2022 17:00:20 +0800 Subject: [PATCH 4/6] fix yml bug --- .github/workflows/release_engine.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_engine.yml b/.github/workflows/release_engine.yml index 0d4480e..c887a11 100644 --- a/.github/workflows/release_engine.yml +++ b/.github/workflows/release_engine.yml @@ -57,7 +57,7 @@ jobs: cd ${{ github.workspace }} && \ echo "${{ github.event.repository.name }},version,${{ steps.release.outputs.VERSION }}" >> version.txt && \ echo "${{ github.event.repository.name }},commit_hash,${GITHUB_SHA}" >> version.txt \ - MAIN_STREAM_VERSION=`echo ${{ steps.release.outputs.version }} | awk '{split($0,a,".");printf "%d.%d.x",a[1],a[2];}` + export MAIN_STREAM_VERSION=`echo ${{ steps.release.outputs.version }} | awk '{split($0,a,".");printf "%d.%d.x",a[1],a[2];}` echo "REPLACE INTO project_version_control (version, component_name, component_version_hash) VALUES('${{ steps.release.outputs.version }}', '${{ github.event.repository.name }}', '${GITHUB_SHA}');" >> ./docker/version.sql echo "REPLACE INTO project_version_control (version, component_name) VALUES('${{ MAIN_STREAM_VERSION }}', 'DongTai');" >> ./docker/version.sql From eaeecbef3de01749329e48aa45401c028b0dc6d2 Mon Sep 17 00:00:00 2001 From: Bidaya0 Date: Mon, 24 Jan 2022 16:42:26 +0800 Subject: [PATCH 5/6] Update release_engine.yml --- .github/workflows/release_engine.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release_engine.yml b/.github/workflows/release_engine.yml index c887a11..33ae852 100644 --- a/.github/workflows/release_engine.yml +++ b/.github/workflows/release_engine.yml @@ -50,6 +50,9 @@ jobs: TAG_NAME=${{ github.event.release.tag_name }} ID=`echo ${TAG_NAME##v}` echo "::set-output name=VERSION::$ID" + - id: version + MAIN_STREAM_VERSION=`echo ${{ steps.release.outputs.version }} | awk '{split($0,a,".");printf "%d.%d.x",a[1],a[2];}'` + echo "::set-output name=main_stream_version::$MAIN_STREAM_VERSION" - name: Generate version file run: | @@ -59,7 +62,7 @@ jobs: echo "${{ github.event.repository.name }},commit_hash,${GITHUB_SHA}" >> version.txt \ export MAIN_STREAM_VERSION=`echo ${{ steps.release.outputs.version }} | awk '{split($0,a,".");printf "%d.%d.x",a[1],a[2];}` echo "REPLACE INTO project_version_control (version, component_name, component_version_hash) VALUES('${{ steps.release.outputs.version }}', '${{ github.event.repository.name }}', '${GITHUB_SHA}');" >> ./docker/version.sql - echo "REPLACE INTO project_version_control (version, component_name) VALUES('${{ MAIN_STREAM_VERSION }}', 'DongTai');" >> ./docker/version.sql + echo "REPLACE INTO project_version_control (version, component_name) VALUES('${{ steps.version.outputs.main_stream_version }}', 'DongTai');" >> ./docker/version.sql - name: Upload version file to oss id: upload_version_file_to_oss From 3379d4d07d5b607aecd258e1c89c538eb9dc6f6c Mon Sep 17 00:00:00 2001 From: Bidaya0 Date: Mon, 24 Jan 2022 16:43:44 +0800 Subject: [PATCH 6/6] Update deploy_test.yml --- .github/workflows/deploy_test.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml index 54a54b1..f79163a 100644 --- a/.github/workflows/deploy_test.yml +++ b/.github/workflows/deploy_test.yml @@ -95,11 +95,16 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - + + - id: version + run: | + MAIN_STREAM_VERSION=`echo ${{ github.run_number }}.0.0 | awk '{split($0,a,".");printf "%d.%d.x",a[1],a[2];}'` + echo "::set-output name=main_stream_version::$MAIN_STREAM_VERSION" + - name: Generate version file run: | echo "REPLACE INTO project_version_control (version, component_name, component_version_hash) VALUES('${{ github.run_number }}.0.0', '${{ github.event.repository.name }}', '${GITHUB_SHA}');" >> ./docker/version.sql - echo "REPLACE INTO project_version_control (version, component_name) VALUES('${{ github.run_number }}.0.0', 'DongTai');" >> ./docker/version.sql + echo "REPLACE INTO project_version_control (version, component_name) VALUES('${{ steps.version.outputs.main_stream_version }}', 'DongTai');" >> ./docker/version.sql - name: Login to DockerHub uses: docker/login-action@v1