Browse Source

init

master
wxz 2 years ago
commit
5702aecca3
  1. 34
      .gitignore
  2. 4
      README.md
  3. 144
      docker-compose-build.yml
  4. 1
      lastcommit.txt
  5. 170
      main.py
  6. 228
      pom.xml
  7. 7
      test.py
  8. 7
      版权声明.txt

34
.gitignore

@ -0,0 +1,34 @@
# Created by .ignore support plugin (hsz.mobi)
### Java template
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea/
*.iml
target/
.DS_Store
epmet-saas
venv
__pycache__

4
README.md

@ -0,0 +1,4 @@
## epmet-cloud
党群e事通后端服务相关代码库

144
docker-compose-build.yml

@ -0,0 +1,144 @@
version : '3.8'
services:
epmet-admin-server:
build:
context: .
dockerfile: ./epmet-module/epmet-admin/Dockerfile_while
epmet-auth:
build:
context: .
dockerfile: ./epmet-auth/Dockerfile_while
epmet-gateway:
build:
context: .
dockerfile: ./epmet-gateway/Dockerfile_while
epmet-user-server:
build:
context: .
dockerfile: ./epmet-legacy-module/epmet-user/epmet-user-server/Dockerfile_while
data-aggregator-server:
build:
context: .
dockerfile: ./epmet-legacy-module/data-aggregator/data-aggregator-server/Dockerfile_while
data-report-server:
build:
context: .
dockerfile: ./epmet-legacy-module/data-report/data-report-server/Dockerfile_while
data-statistical-server:
build:
context: .
dockerfile: ./epmet-legacy-module/data-statistical/data-statistical-server/Dockerfile_while
epmet-actual-base:
build:
context: .
dockerfile: ./epmet-module/epmet-actual-base/Dockerfile_while
common-service-server:
build:
context: .
dockerfile: ./epmet-legacy-module/epmet-common-service/common-service-server/Dockerfile_while
epmet-ext-server:
build:
context: .
dockerfile: ./epmet-legacy-module/epmet-ext/epmet-ext-server/Dockerfile_while
epmet-heart-server:
build:
context: .
dockerfile: ./epmet-legacy-module/epmet-heart/epmet-heart-server/Dockerfile_while
epmet-job-server:
build:
context: .
dockerfile: ./epmet-legacy-module/epmet-job/epmet-job-server/Dockerfile_while
epmet-message-server:
build:
context: .
dockerfile: ./epmet-legacy-module/epmet-message/epmet-message-server/Dockerfile_while
epmet-oss-server:
build:
context: .
dockerfile: ./epmet-legacy-module/epmet-oss/epmet-oss-server/Dockerfile_while
epmet-point-server:
build:
context: .
dockerfile: ./epmet-legacy-module/epmet-point/epmet-point-server/Dockerfile_while
epmet-third-server:
build:
context: .
dockerfile: ./epmet-legacy-module/epmet-third/epmet-third-server/Dockerfile_while
gov-access-server:
build:
context: .
dockerfile: ./epmet-legacy-module/gov-access/gov-access-server/Dockerfile_while
gov-grid-server:
build:
context: .
dockerfile: ./epmet-legacy-module/gov-grid/gov-grid-server/Dockerfile_while
gov-issue-server:
build:
context: .
dockerfile: ./epmet-legacy-module/gov-issue/gov-issue-server/Dockerfile_while
gov-mine-server:
build:
context: .
dockerfile: ./epmet-legacy-module/gov-mine/gov-mine-server/Dockerfile_while
gov-org-server:
build:
context: .
dockerfile: ./epmet-legacy-module/gov-org/gov-org-server/Dockerfile_while
gov-project-server:
build:
context: .
dockerfile: ./epmet-legacy-module/gov-project/gov-project-server/Dockerfile_while
gov-voice-server:
build:
context: .
dockerfile: ./epmet-legacy-module/gov-voice/gov-voice-server/Dockerfile_while
open-data-worker-server:
build:
context: .
dockerfile: ./epmet-legacy-module/open-data-worker/open-data-worker-server/Dockerfile_while
oper-access-server:
build:
context: .
dockerfile: ./epmet-legacy-module/oper-access/oper-access-server/Dockerfile_while
oper-crm-server:
build:
context: .
dockerfile: ./epmet-legacy-module/oper-crm/oper-crm-server/Dockerfile_while
oper-customize-server:
build:
context: .
dockerfile: ./epmet-legacy-module/oper-customize/oper-customize-server/Dockerfile_while
resi-group-server:
build:
context: .
dockerfile: ./epmet-legacy-module/resi-group/resi-group-server/Dockerfile_while
resi-guide-server:
build:
context: .
dockerfile: ./epmet-legacy-module/resi-guide/resi-guide-server/Dockerfile_while
resi-hall-server:
build:
context: .
dockerfile: ./epmet-legacy-module/resi-hall/resi-hall-server/Dockerfile_while
resi-home-server:
build:
context: .
dockerfile: ./epmet-legacy-module/resi-home/resi-home-server/Dockerfile_while
resi-mine-server:
build:
context: .
dockerfile: ./epmet-legacy-module/resi-mine/resi-mine-server/Dockerfile_while
resi-partymember-server:
build:
context: .
dockerfile: ./epmet-legacy-module/resi-partymember/resi-partymember-server/Dockerfile_while
resi-voice-server:
build:
context: .
dockerfile: ./epmet-module/resi-voice/resi-voice-server/Dockerfile_while
epmet-governance:
build:
context: .
dockerfile: ./epmet-module/epmet-governance/Dockerfile_while
# 使用方式: docker-compose -f docker-compose-dev.yml -f docker-compose-build.yml build epmet-gateway

1
lastcommit.txt

@ -0,0 +1 @@
5b0ad41e70f65873bfcb096b74c4d16e3c7a4898

170
main.py

@ -0,0 +1,170 @@
# This is a sample Python script.
# Press <no shortcut> to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
import os
import re
import requests
from flask import Flask
app = Flask(__name__)
epmet_root_services = ['epmet-auth', 'epmet-gateway']
epmet_root_svc_name_reg = "^([^/]+)/.*$"
epmet_module_svc_name_reg = "^epmet-module/([^/]+)/.*$"
commit_regex = "^([0-9a-z]{40}) .*$"
max_commit_qty = 20
def findIndexOfLastCommit(commits: list, last_commit_ver: str):
idx: int = None
for c in commits:
if c.startswith(last_commit_ver):
return idx
else:
if not idx:
idx = 0
idx += 1
return idx
def findLatestCommits(commits: list, last_commit_ver: str, max_amount: int):
"""
过滤出肯能需要发布服务的提交列表
:param commits:
:param last_commit_ver:
:param max_amount:
:return:
"""
rst: list = []
idx: int = 0
for c in commits:
if idx > max_amount:
return rst
commit_ver = c.split(" ")[0]
if commit_ver != last_commit_ver:
rst.append(commit_ver)
idx += 1
if commit_ver == last_commit_ver:
return rst
return rst
def findModuleList(commits: str):
"""
根据提交列表找出所有需要发布的服务模块
:param commits:
:return:
"""
service_set: set = set()
for c in commits:
try:
rst = os.popen("cd epmet-saas && git show {} --stat --name-only|grep 'epmet-'".format(c))
files = rst.readlines()
for file in files:
svc_name = find_service_name_from_file(file)
if svc_name:
# 有些文件可能是不需要发的,比如commons/clients等
service_set.add(svc_name)
finally:
rst.close()
return service_set
def find_service_name_from_file(file_rel_path: str):
"""
根据提交的文件路径找出他的服务名称
:param file_rel_path:
:return:
"""
if file_rel_path.startswith("epmet-module/"):
match = re.match(epmet_module_svc_name_reg, file_rel_path)
return match.group(1)
if file_rel_path.startswith("epmet-gateway") or file_rel_path.startswith("epmet-auth"):
match = re.match(epmet_root_svc_name_reg, file_rel_path)
return match.group(1)
def read_last_commit_ver():
"""
读取上次发布到的版本号(包含)
:return:
"""
with open('./lastcommit.txt', 'rt') as lastcommit_file:
line_contents = lastcommit_file.readlines()
if len(line_contents) > 0:
return line_contents[0]
def write_last_commit_ver(new_ver):
"""
写入上次发布到的版本号(包含)
:return:
"""
with open('./lastcommit.txt', 'wt') as lastcommit_file:
lastcommit_file.write(new_ver)
def deploy_svcs(svc_list):
"""
发布服务
:param svc_list:
:return:
"""
for svc in svc_list:
rst = requests.post(
"http://192.168.1.140:9610/jenkins/generic-webhook-trigger/invoke?MODULE_NAME={}&OPERATION=Deploy&token=11a600e78ec001d7864a73f7cf1555ae1a".format(
svc))
print(rst.content.decode('utf-8'))
def do():
# 切换分支
os.system("cd epmet-saas && git checkout dev")
# 更新代码
os.system("cd epmet-saas && git pull")
last_commit_ver = read_last_commit_ver()
try:
stream = os.popen("cd epmet-saas && git log --pretty=oneline --no-merges -20")
commits = stream.readlines()
# 根据commits找出最近提交的commits
last_commits = findLatestCommits(commits, last_commit_ver, max_commit_qty)
if not last_commits or len(last_commits) == 0:
print("没有找到可发布的提交")
return
# 找到这些commits下提交的文件对应的微服务
svc_set = findModuleList(last_commits)
# 记录本次发布版本号
write_last_commit_ver(last_commits[0])
# 执行jenkins远程部署
print("要发布的服务:", svc_set)
deploy_svcs(svc_set)
finally:
stream.close()
@app.route(rule='/on-dev-push', methods=['GET'])
def on_dev_push():
do()
return "success"
app.run(host="0.0.0.0", port=7998, debug=True) # 多线程模式
# python main.py runserver 0.0.0.0:7999

228
pom.xml

@ -0,0 +1,228 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.11.RELEASE</version>
</parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-saas</artifactId>
<version>2.0.0</version>
<packaging>pom</packaging>
<description>Elink Party Masses Easily Together Saas</description>
<organization>
<name>青岛亿联信息科技股份有限公司</name>
<url>http://www.elinkchina.com.cn/</url>
</organization>
<modules>
<module>epmet-commons</module>
<module>epmet-gateway</module>
<module>epmet-auth</module>
<module>epmet-module</module>
<module>epmet-clients</module>
<module>epmet-cloud-generator</module>
<!--<module>epmet-legacy-module</module>-->
</modules>
<properties>
<alibaba-dingtalk-service-sdk.version>2.0.0</alibaba-dingtalk-service-sdk.version>
<kotlin-stdlib.version>1.3.70</kotlin-stdlib.version>
<okhttp.version>4.9.0</okhttp.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring.cloud.version>Greenwich.SR4</spring.cloud.version>
<spring.cloud.alibaba.version>2.1.0.RELEASE</spring.cloud.alibaba.version>
<spring.boot.admin.version>2.1.6</spring.boot.admin.version>
<mysql.version>8.0.18</mysql.version>
<epmet.version>2.0.0</epmet.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring.cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring.cloud.alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!--<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>-->
<!-- 钉钉机器人 -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
<version>${alibaba-dingtalk-service-sdk.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin-stdlib.version}</version>
</dependency>
<!-- epmet commons通用jar start -->
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-common-clienttoken</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-dynamic-datasource</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-extapp-auth</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-feignclient</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-mybatis</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-openapi</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-rocketmq</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-security</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-service-call</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-thirdplat</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-tools</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-tools-phone</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-tools-wx-ma</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-tools-wx-mp</artifactId>
<version>${epmet.version}</version>
</dependency>
<!-- epmet commons通用 jar end -->
<!-- epmet clients jar start -->
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-actual-base-client</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-admin-client</artifactId>
<version>${epmet.version}</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-auth-client</artifactId>
<version>${epmet.version}</version>
</dependency>
<!-- epmet clients jar end -->
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>epmet</id>
<name>maven-releases</name>
<url>https://nexus.elinkservice.cn/repository/maven-releases/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>epmet</id>
<url>https://nexus.elinkservice.cn/repository/maven-releases/</url>
</repository>
</distributionManagement>
</project>

7
test.py

@ -0,0 +1,7 @@
import re
epmet_module_svc_name_reg = "^epmet-module/([^/]+)/.*$"
url = "epmet-module/gov-org-server/abc.java"
match = re.match(epmet_module_svc_name_reg, url)
print(match.groups())

7
版权声明.txt

@ -0,0 +1,7 @@
renren-cloud【人人微服务】版权声明
1. renren-cloud【人人微服务】已申请软件著作权,未经授权的企业或个人,请购买正版授权,否则我们会根据事态轻重追究相应法律责任。
2. 授权者可将授权后的产品用于任意符合国家法律法规的应用平台,并且不受域名和项目数量限制。
3. 授权者如果使用人人开源付费产品开发的商业项目(如ERP、CMS等),需保留授权产品的源码头注释和出处。
4. 授权者务必尊重知识产权,严格保证不恶意传播产品源码、不得直接对授权的产品本身进行二次转售或倒卖、不得对授权的产品进行简单包装后声称为自己的产品等。否则我们有权利收回产品授权,并根据事态轻重追究相应法律责任。
5. 最终解释权归 renren.io 所有
Loading…
Cancel
Save