diff --git a/press/docker/config/redis-cache.conf b/press/docker/config/redis-cache.conf index 55cd8f6c88..e16613ee0a 100644 --- a/press/docker/config/redis-cache.conf +++ b/press/docker/config/redis-cache.conf @@ -3,7 +3,7 @@ dir /home/frappe/frappe-bench/config/pids pidfile /home/frappe/frappe-bench/config/pids/redis-cache.pid bind 127.0.0.1 port 13000 -maxmemory 512mb +maxmemory {{ doc.redis_cache_size }}mb maxmemory-policy allkeys-lru appendonly no save "" diff --git a/press/patches.txt b/press/patches.txt index 79d1a06292..7b0f0e1d0c 100644 --- a/press/patches.txt +++ b/press/patches.txt @@ -135,3 +135,4 @@ press.press.doctype.server.patches.set_plan_and_subscription press.patches.v0_7_0.move_site_db_access_users_to_site_db_perm_manager press.press.doctype.drip_email.patches.set_correct_field_for_html press.patches.v0_7_0.set_label_for_site_database_user +press.press.doctype.press_settings.patches.set_redis_cache_size \ No newline at end of file diff --git a/press/press/doctype/deploy_candidate/deploy_candidate.json b/press/press/doctype/deploy_candidate/deploy_candidate.json index 78b9d12ac3..de195f436a 100644 --- a/press/press/doctype/deploy_candidate/deploy_candidate.json +++ b/press/press/doctype/deploy_candidate/deploy_candidate.json @@ -36,6 +36,7 @@ "docker_image_tag", "feature_flags_section", "is_redisearch_enabled", + "redis_cache_size", "use_app_cache", "compress_app_cache", "column_break_tkdd", @@ -415,6 +416,13 @@ "fieldname": "no_cache", "fieldtype": "Check", "label": "No Cache" + }, + { + "default": "512", + "fetch_from": "group.redis_cache_size", + "fieldname": "redis_cache_size", + "fieldtype": "Int", + "label": "Redis Cache Size (MB)" } ], "links": [ @@ -431,7 +439,7 @@ "link_fieldname": "document_name" } ], - "modified": "2024-06-21 14:12:47.335402", + "modified": "2024-12-27 11:59:09.917364", "modified_by": "Administrator", "module": "Press", "name": "Deploy Candidate", diff --git a/press/press/doctype/deploy_candidate/deploy_candidate.py b/press/press/doctype/deploy_candidate/deploy_candidate.py index 8661e32b9b..be0bd45a80 100644 --- a/press/press/doctype/deploy_candidate/deploy_candidate.py +++ b/press/press/doctype/deploy_candidate/deploy_candidate.py @@ -118,6 +118,7 @@ class DeployCandidate(Document): pending_duration: DF.Time | None pending_end: DF.Datetime | None pending_start: DF.Datetime | None + redis_cache_size: DF.Int retry_count: DF.Int scheduled_time: DF.Datetime | None status: DF.Literal["Draft", "Scheduled", "Pending", "Preparing", "Running", "Success", "Failure"] diff --git a/press/press/doctype/press_settings/patches/set_redis_cache_size.py b/press/press/doctype/press_settings/patches/set_redis_cache_size.py new file mode 100644 index 0000000000..0684ded4c3 --- /dev/null +++ b/press/press/doctype/press_settings/patches/set_redis_cache_size.py @@ -0,0 +1,11 @@ +import frappe +from frappe.core.utils import find + + +def execute(): + frappe.reload_doctype("Press Settings") + settings = frappe.get_single("Press Settings") + if not settings.redis_cache_size: + redis_cache_size_field = find(settings.meta.fields, lambda x: x.fieldname == "redis_cache_size") + settings.redis_cache_size = redis_cache_size_field.default + settings.save() diff --git a/press/press/doctype/press_settings/press_settings.json b/press/press/doctype/press_settings/press_settings.json index 56f2644310..640b2f7e17 100644 --- a/press/press/doctype/press_settings/press_settings.json +++ b/press/press/doctype/press_settings/press_settings.json @@ -178,6 +178,8 @@ "use_staging_ca", "ssh_section", "ssh_certificate_authority", + "bench_section", + "redis_cache_size", "monitoring_section", "monitor_server", "monitor_token", @@ -193,7 +195,6 @@ "column_break_rdlr", "disable_auto_retry", "disable_agent_job_deduplication", - "enable_email_pre_verification", "section_break_jstu", "enable_app_grouping", "default_apps", @@ -1268,15 +1269,20 @@ "options": "App Group" }, { - "default": "0", - "fieldname": "enable_email_pre_verification", - "fieldtype": "Check", - "label": "Enable Email Pre-Verification" + "fieldname": "bench_section", + "fieldtype": "Section Break", + "label": "Bench" + }, + { + "default": "512", + "fieldname": "redis_cache_size", + "fieldtype": "Int", + "label": "Redis Cache Size (MB)" } ], "issingle": 1, "links": [], - "modified": "2024-12-10 15:07:57.494659", + "modified": "2024-12-27 11:44:09.454080", "modified_by": "Administrator", "module": "Press", "name": "Press Settings", diff --git a/press/press/doctype/press_settings/press_settings.py b/press/press/doctype/press_settings/press_settings.py index bc4c1a559b..507d92e1b1 100644 --- a/press/press/doctype/press_settings/press_settings.py +++ b/press/press/doctype/press_settings/press_settings.py @@ -64,7 +64,6 @@ class PressSettings(Document): domain: DF.Link | None eff_registration_email: DF.Data enable_app_grouping: DF.Check - enable_email_pre_verification: DF.Check enable_google_oauth: DF.Check enable_site_pooling: DF.Check enforce_storage_limits: DF.Check @@ -115,6 +114,7 @@ class PressSettings(Document): razorpay_key_secret: DF.Password | None razorpay_webhook_secret: DF.Data | None realtime_job_updates: DF.Check + redis_cache_size: DF.Int remote_access_key_id: DF.Data | None remote_link_expiry: DF.Int remote_secret_access_key: DF.Password | None diff --git a/press/press/doctype/release_group/release_group.json b/press/press/doctype/release_group/release_group.json index c66ede4e43..cbf66e714c 100644 --- a/press/press/doctype/release_group/release_group.json +++ b/press/press/doctype/release_group/release_group.json @@ -29,6 +29,7 @@ "column_break_14", "bench_config", "gunicorn_threads_per_worker", + "redis_cache_size", "automatic_worker_allocation_section", "min_gunicorn_workers", "min_background_workers", @@ -367,10 +368,16 @@ "fieldtype": "Link", "label": "Build Server", "options": "Server" + }, + { + "default": "512", + "fieldname": "redis_cache_size", + "fieldtype": "Int", + "label": "Redis Cache Size (MB)" } ], "links": [], - "modified": "2024-09-17 14:44:01.541194", + "modified": "2024-12-27 11:58:29.907938", "modified_by": "Administrator", "module": "Press", "name": "Release Group", diff --git a/press/press/doctype/release_group/release_group.py b/press/press/doctype/release_group/release_group.py index 4079ddae08..b7ab051757 100644 --- a/press/press/doctype/release_group/release_group.py +++ b/press/press/doctype/release_group/release_group.py @@ -84,7 +84,9 @@ class ReleaseGroup(Document, TagHelpers): from press.press.doctype.release_group_variable.release_group_variable import ( ReleaseGroupVariable, ) - from press.press.doctype.resource_tag.resource_tag import ResourceTag + from press.press.doctype.resource_tag.resource_tag import ( + ResourceTag, + ) apps: DF.Table[ReleaseGroupApp] bench_config: DF.Code | None @@ -111,6 +113,7 @@ class ReleaseGroup(Document, TagHelpers): mounts: DF.Table[ReleaseGroupMount] packages: DF.Table[ReleaseGroupPackage] public: DF.Check + redis_cache_size: DF.Int saas_app: DF.Link | None saas_bench: DF.Check servers: DF.Table[ReleaseGroupServer] @@ -370,11 +373,16 @@ def update_config_in_release_group(self, common_site_config, bench_config): else: value = d.value self.append("common_site_config_table", {"key": d.key, "value": value, "type": d.type}) + # redis_cache_size is a field on release group but we want to treat it as config key + # TODO: add another interface for updating similar values + if d["key"] == "redis_cache_size": + self.redis_cache_size = int(d.value) for d in bench_config: if d["key"] == "http_timeout": # http_timeout should be the only thing configurable in bench_config self.bench_config = json.dumps({"http_timeout": int(d["value"])}, indent=4) + if bench_config == []: self.bench_config = json.dumps({})