From 1bb25bb89d70d10921613e939421227d0dca49ec Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 10 Dec 2024 12:17:32 +0100 Subject: [PATCH 1/4] :fire: Remove file-xlog-gc task It is no longer necessary because snapshots are managed by the objects-gc task --- backend/src/app/config.clj | 2 - backend/src/app/main.clj | 5 -- backend/src/app/rpc/commands/files_update.clj | 9 --- backend/src/app/tasks/file_xlog_gc.clj | 64 ------------------- 4 files changed, 80 deletions(-) delete mode 100644 backend/src/app/tasks/file_xlog_gc.clj diff --git a/backend/src/app/config.clj b/backend/src/app/config.clj index 4824a5d78..6e9f31b31 100644 --- a/backend/src/app/config.clj +++ b/backend/src/app/config.clj @@ -42,7 +42,6 @@ :rpc-rlimit-config "resources/rlimit.edn" :rpc-climit-config "resources/climit.edn" - :auto-file-snapshot-total 10 :auto-file-snapshot-every 5 :auto-file-snapshot-timeout "3h" @@ -101,7 +100,6 @@ [:telemetry-uri {:optional true} :string] [:telemetry-with-taiga {:optional true} ::sm/boolean] ;; DELETE - [:auto-file-snapshot-total {:optional true} ::sm/int] [:auto-file-snapshot-every {:optional true} ::sm/int] [:auto-file-snapshot-timeout {:optional true} ::dt/duration] diff --git a/backend/src/app/main.clj b/backend/src/app/main.clj index 1ad2fcc4c..b971eafdd 100644 --- a/backend/src/app/main.clj +++ b/backend/src/app/main.clj @@ -349,7 +349,6 @@ :file-gc (ig/ref :app.tasks.file-gc/handler) :file-gc-scheduler (ig/ref :app.tasks.file-gc-scheduler/handler) :offload-file-data (ig/ref :app.tasks.offload-file-data/handler) - :file-xlog-gc (ig/ref :app.tasks.file-xlog-gc/handler) :tasks-gc (ig/ref :app.tasks.tasks-gc/handler) :telemetry (ig/ref :app.tasks.telemetry/handler) :storage-gc-deleted (ig/ref ::sto.gc-deleted/handler) @@ -405,10 +404,6 @@ {::db/pool (ig/ref ::db/pool) ::sto/storage (ig/ref ::sto/storage)} - :app.tasks.file-xlog-gc/handler - {::db/pool (ig/ref ::db/pool) - ::sto/storage (ig/ref ::sto/storage)} - :app.tasks.telemetry/handler {::db/pool (ig/ref ::db/pool) ::http.client/client (ig/ref ::http.client/client) diff --git a/backend/src/app/rpc/commands/files_update.clj b/backend/src/app/rpc/commands/files_update.clj index 89f75b580..a4bdbbe20 100644 --- a/backend/src/app/rpc/commands/files_update.clj +++ b/backend/src/app/rpc/commands/files_update.clj @@ -223,15 +223,6 @@ (let [storage (sto/resolve cfg ::db/reuse-conn true)] (some->> (:data-ref-id file) (sto/touch-object! storage)))) - (-> cfg - (assoc ::wrk/task :file-xlog-gc) - (assoc ::wrk/label (str "xlog:" (:id file))) - (assoc ::wrk/params {:file-id (:id file)}) - (assoc ::wrk/delay (dt/duration "5m")) - (assoc ::wrk/dedupe true) - (assoc ::wrk/priority 1) - (wrk/submit!)) - (persist-file! cfg file) (let [params (assoc params :file file) diff --git a/backend/src/app/tasks/file_xlog_gc.clj b/backend/src/app/tasks/file_xlog_gc.clj deleted file mode 100644 index f0654916c..000000000 --- a/backend/src/app/tasks/file_xlog_gc.clj +++ /dev/null @@ -1,64 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. -;; -;; Copyright (c) KALEIDOS INC - -(ns app.tasks.file-xlog-gc - (:require - [app.common.logging :as l] - [app.config :as cf] - [app.db :as db] - [integrant.core :as ig])) - -;; Get the latest available snapshots without exceeding the total -;; snapshot limit -(def ^:private sql:get-latest-snapshots - "SELECT fch.id, fch.created_at - FROM file_change AS fch - WHERE fch.file_id = ? - AND fch.created_by = 'system' - AND fch.data IS NOT NULL - AND fch.deleted_at > now() - ORDER BY fch.created_at DESC - LIMIT ?") - -;; Mark all snapshots that are outside the allowed total threshold -;; available for the GC -(def ^:private sql:delete-snapshots - "UPDATE file_change - SET deleted_at = now() - WHERE file_id = ? - AND deleted_at > now() - AND data IS NOT NULL - AND created_by = 'system' - AND created_at < ?") - -(defn- get-alive-snapshots - [conn file-id] - (let [total (cf/get :auto-file-snapshot-total 10) - snapshots (db/exec! conn [sql:get-latest-snapshots file-id total])] - (not-empty snapshots))) - -(defn- delete-old-snapshots! - [{:keys [::db/conn] :as cfg} file-id] - (when-let [snapshots (get-alive-snapshots conn file-id)] - (let [last-date (-> snapshots peek :created-at) - result (db/exec-one! conn [sql:delete-snapshots file-id last-date])] - (l/inf :hint "delete old file snapshots" - :file-id (str file-id) - :current (count snapshots) - :deleted (db/get-update-count result))))) - -(defmethod ig/assert-key ::handler - [_ params] - (assert (db/pool? (::db/pool params)) "expected a valid database pool")) - -(defmethod ig/init-key ::handler - [_ cfg] - (fn [{:keys [props] :as task}] - (let [file-id (:file-id props)] - (assert (uuid? file-id) "expected file-id on props") - (-> cfg - (assoc ::db/rollback (:rollback props false)) - (db/tx-run! delete-old-snapshots! file-id))))) From d8964a69bc42ca32fc0b381412f807e267c4e78f Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Tue, 10 Dec 2024 13:33:04 +0100 Subject: [PATCH 2/4] :sparkles: Fix test A/B add share button to the workspace --- frontend/src/app/main/ui/workspace/right_header.cljs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/ui/workspace/right_header.cljs b/frontend/src/app/main/ui/workspace/right_header.cljs index 17ea3f5ce..994416cf9 100644 --- a/frontend/src/app/main/ui/workspace/right_header.cljs +++ b/frontend/src/app/main/ui/workspace/right_header.cljs @@ -250,7 +250,9 @@ :on-click toggle-history} i/history]]) - (when (cf/external-feature-flag "share-01" "test") + (when (and + (not (:is-default team)) + (cf/external-feature-flag "share-01" "test")) [:a {:class (stl/css :viewer-btn) :title (tr "workspace.header.share") :on-click open-share-dialog} From b9cb415507b7fd2b6a21c0566a25e1fa5cfb07f0 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 10 Dec 2024 14:41:00 +0100 Subject: [PATCH 3/4] :bug: Remove file history versions menu options on view mode --- .../src/app/main/ui/workspace/main_menu.cljs | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/main_menu.cljs b/frontend/src/app/main/ui/workspace/main_menu.cljs index f002f90a2..4728c068a 100644 --- a/frontend/src/app/main/ui/workspace/main_menu.cljs +++ b/frontend/src/app/main/ui/workspace/main_menu.cljs @@ -613,23 +613,25 @@ [:span {:class (stl/css :item-name)} (tr "dashboard.add-shared")]])) - [:div {:class (stl/css :separator)}] + (when can-edit + [:* + [:div {:class (stl/css :separator)}] - [:> dropdown-menu-item* {:class (stl/css :submenu-item) - :on-click on-pin-version - :on-key-down on-pin-version-key-down - :id "file-menu-show-version-history"} - [:span {:class (stl/css :item-name)} - (tr "dashboard.create-version-menu")]] + [:> dropdown-menu-item* {:class (stl/css :submenu-item) + :on-click on-pin-version + :on-key-down on-pin-version-key-down + :id "file-menu-show-version-history"} + [:span {:class (stl/css :item-name)} + (tr "dashboard.create-version-menu")]] - [:> dropdown-menu-item* {:class (stl/css :submenu-item) - :on-click on-show-version-history - :on-key-down on-show-version-history-key-down - :id "file-menu-show-version-history"} - [:span {:class (stl/css :item-name)} - (tr "dashboard.show-version-history")]] + [:> dropdown-menu-item* {:class (stl/css :submenu-item) + :on-click on-show-version-history + :on-key-down on-show-version-history-key-down + :id "file-menu-show-version-history"} + [:span {:class (stl/css :item-name)} + (tr "dashboard.show-version-history")]] - [:div {:class (stl/css :separator)}] + [:div {:class (stl/css :separator)}]]) [:> dropdown-menu-item* {:class (stl/css :submenu-item) :on-click on-export-shapes From 2440c81b421b6953fd1de697ed80aea76473f2a0 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 10 Dec 2024 10:52:42 +0100 Subject: [PATCH 4/4] :books: Recommended settings for selfhost --- docs/technical-guide/getting-started.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/technical-guide/getting-started.md b/docs/technical-guide/getting-started.md index 94cea0268..7fc6da894 100644 --- a/docs/technical-guide/getting-started.md +++ b/docs/technical-guide/getting-started.md @@ -30,6 +30,15 @@ and do not want to depend on any external provider, or need to do any special cu Or you can try other options, offered by Penpot community. +## Recommended settings +To self-host Penpot, you’ll need a server with the following specifications: + +* **CPU:** 1-2 CPUs +* **RAM:** 4 GiB of RAM +* **Disk Space:** Disk requirements depend on your usage. Disk usage primarily involves the database and any files uploaded by users. + +This setup should be sufficient for a smooth experience with typical usage (your mileage may vary). + ## Install with Elestio This section explains how to get Penpot up and running using