Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:WeBankPartners/wecube-plugins-itsdan…
Browse files Browse the repository at this point in the history
…gerous into dev
  • Loading branch information
pobu168 committed Nov 14, 2024
2 parents 20cebe6 + d5038b2 commit ae12930
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ RUN apt update && apt-get -y install gcc python3-dev swig libssl-dev && \
# Use app:app to run gunicorn
RUN mkdir -p /etc/itsdangerous/
RUN mkdir -p /var/log/itsdangerous/
RUN mkdir -p /tmp/artifacts/
COPY etc /etc/itsdangerous
# RUN adduser --disabled-password app
# RUN chown -R app:app /etc/itsdangerous/
Expand Down
3 changes: 2 additions & 1 deletion build/register.xml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<!-- 4.系统参数 - 描述运行本插件包需要的系统参数 -->
<systemParameters>
<systemParameter name="ITSDANGEROUS_LOG_LEVEL" scopeType="plugins" defaultValue="info" />
<systemParameter name="ITSDANGEROUS_CACHE_CLEANUP_INTERVAL_MIN" scopeType="plugins" defaultValue="10" />
</systemParameters>

<!-- 5.权限设定 -->
Expand All @@ -27,7 +28,7 @@

<!-- 6.运行资源 - 描述部署运行本插件包需要的基础资源(如主机、虚拟机、容器、数据库等) -->
<resourceDependencies>
<docker imageName="{{IMAGENAME}}" containerName="{{CONTAINERNAME}}" portBindings="{{ALLOCATE_PORT}}:9000" volumeBindings="/etc/localtime:/etc/localtime,{{BASE_MOUNT_PATH}}/itsdangerous/logs:/var/log/itsdangerous,{{BASE_MOUNT_PATH}}/certs:/certs" envVariables="ITSDANGEROUS_DB_USERNAME={{DB_USER}},ITSDANGEROUS_DB_PASSWORD={{DB_PWD}},ITSDANGEROUS_DB_HOSTIP={{DB_HOST}},ITSDANGEROUS_DB_HOSTPORT={{DB_PORT}},ITSDANGEROUS_DB_SCHEMA={{DB_SCHEMA}},GATEWAY_URL={{GATEWAY_URL}},JWT_SIGNING_KEY={{JWT_SIGNING_KEY}},WECUBE_S3_ACCESS_KEY={{S3_ACCESS_KEY}},WECUBE_S3_SECRET_KEY={{S3_SECRET_KEY}},SUB_SYSTEM_CODE={{SUB_SYSTEM_CODE}},SUB_SYSTEM_KEY={{SUB_SYSTEM_KEY}},ITSDANGEROUS_LOG_LEVEL={{ITSDANGEROUS_LOG_LEVEL}}" />
<docker imageName="{{IMAGENAME}}" containerName="{{CONTAINERNAME}}" portBindings="{{ALLOCATE_PORT}}:9000" volumeBindings="{{BASE_MOUNT_PATH}}/cachedir:/tmp/artifacts,/etc/localtime:/etc/localtime,{{BASE_MOUNT_PATH}}/itsdangerous/logs:/var/log/itsdangerous,{{BASE_MOUNT_PATH}}/certs:/certs" envVariables="ITSDANGEROUS_DB_USERNAME={{DB_USER}},ITSDANGEROUS_DB_PASSWORD={{DB_PWD}},ITSDANGEROUS_DB_HOSTIP={{DB_HOST}},ITSDANGEROUS_DB_HOSTPORT={{DB_PORT}},ITSDANGEROUS_DB_SCHEMA={{DB_SCHEMA}},GATEWAY_URL={{GATEWAY_URL}},JWT_SIGNING_KEY={{JWT_SIGNING_KEY}},WECUBE_S3_ACCESS_KEY={{S3_ACCESS_KEY}},WECUBE_S3_SECRET_KEY={{S3_SECRET_KEY}},SUB_SYSTEM_CODE={{SUB_SYSTEM_CODE}},SUB_SYSTEM_KEY={{SUB_SYSTEM_KEY}},ITSDANGEROUS_LOG_LEVEL={{ITSDANGEROUS_LOG_LEVEL}},ITSDANGEROUS_CACHE_CLEANUP_INTERVAL_MIN={{ITSDANGEROUS_CACHE_CLEANUP_INTERVAL_MIN}}" />
<mysql schema="itsdangerous" initFileName="init.sql" upgradeFileName="upgrade.sql" />
</resourceDependencies>

Expand Down
4 changes: 3 additions & 1 deletion etc/wecube_plugins_itsdangerous.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"sub_system_code": "ENV@SUB_SYSTEM_CODE",
"sub_system_key": "ENV@SUB_SYSTEM_KEY",
"platform_timezone": "ENV@TZ",
"log_level": "ENV@ITSDANGEROUS_LOG_LEVEL"
"log_level": "ENV@ITSDANGEROUS_LOG_LEVEL",
"cache_cleanup_interval_min": "ENV@ITSDANGEROUS_CACHE_CLEANUP_INTERVAL_MIN"
},
"log": {
"gunicorn_access": "/var/log/itsdangerous/access.log",
Expand Down Expand Up @@ -58,6 +59,7 @@
"global_limits": null
},
"pakcage_cache_dir": "/tmp/artifacts/",
"pakcage_cache_cleanup_interval_min": "${cache_cleanup_interval_min}",
"wecube": {
"s3": {
"access_key": "${s3_access_key}",
Expand Down
8 changes: 7 additions & 1 deletion wecube_plugins_itsdangerous/server/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@

def cleanup_cached_dir():
try:
max_delta = 24 * 60 * 60
interval_min = 10
try:
interval_min = int(CONF.pakcage_cache_cleanup_interval_min)
except Exception as e:
LOG.error("Invalid package_cache_cleanup_interval_min: %s",
CONF.pakcage_cache_cleanup_interval_min)
max_delta = interval_min * 60
base_dir = CONF.pakcage_cache_dir
if os.path.exists(base_dir):
for name in list(os.listdir(base_dir)):
Expand Down
3 changes: 2 additions & 1 deletion wecube_plugins_itsdangerous/server/wsgi_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def decrypt_rsa(secret_key, encrypt_text):


@config.intercept('db_username', 'db_hostip', 'db_hostport', 'db_schema', 'gateway_url', 's3_access_key',
's3_secret_key', 'jwt_signing_key', 'platform_timezone', 'sub_system_code', 'sub_system_key', 'log_level')
's3_secret_key', 'jwt_signing_key', 'platform_timezone', 'sub_system_code', 'sub_system_key', 'log_level',
'cache_cleanup_interval_min')
def get_env_value(value, origin_value):
prefix = 'ENV@'
encrypt_prefix = 'RSA@'
Expand Down

0 comments on commit ae12930

Please sign in to comment.