diff --git a/Dockerfile b/Dockerfile index 4293f4c..e1e73c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/ diff --git a/build/register.xml.tpl b/build/register.xml.tpl index dee30fc..e19eb4b 100644 --- a/build/register.xml.tpl +++ b/build/register.xml.tpl @@ -16,6 +16,7 @@ + @@ -27,7 +28,7 @@ - + diff --git a/etc/wecube_plugins_itsdangerous.conf b/etc/wecube_plugins_itsdangerous.conf index f61fdce..196f7d2 100644 --- a/etc/wecube_plugins_itsdangerous.conf +++ b/etc/wecube_plugins_itsdangerous.conf @@ -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", @@ -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}", diff --git a/wecube_plugins_itsdangerous/server/scheduler.py b/wecube_plugins_itsdangerous/server/scheduler.py index 0df29b2..acc5e39 100644 --- a/wecube_plugins_itsdangerous/server/scheduler.py +++ b/wecube_plugins_itsdangerous/server/scheduler.py @@ -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)): diff --git a/wecube_plugins_itsdangerous/server/wsgi_server.py b/wecube_plugins_itsdangerous/server/wsgi_server.py index 3de71e9..b176138 100644 --- a/wecube_plugins_itsdangerous/server/wsgi_server.py +++ b/wecube_plugins_itsdangerous/server/wsgi_server.py @@ -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@'