mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 04:42:59 +02:00
Merge pull request #2001 from penpot/niwinz-telemetry-enhacements-2
Minor improvements
This commit is contained in:
commit
65b6d1e07b
3 changed files with 53 additions and 38 deletions
|
@ -24,9 +24,8 @@ mc mb penpot-s3/penpot -p
|
||||||
|
|
||||||
export AWS_ACCESS_KEY_ID=penpot-devenv
|
export AWS_ACCESS_KEY_ID=penpot-devenv
|
||||||
export AWS_SECRET_ACCESS_KEY=penpot-devenv
|
export AWS_SECRET_ACCESS_KEY=penpot-devenv
|
||||||
export PENPOT_ASSETS_STORAGE_BACKEND=assets-fs
|
export PENPOT_ASSETS_STORAGE_BACKEND=assets-s3
|
||||||
export PENPOT_STORAGE_ASSETS_S3_ENDPOINT=http://minio:9000
|
export PENPOT_STORAGE_ASSETS_S3_ENDPOINT=http://minio:9000
|
||||||
export PENPOT_STORAGE_ASSETS_S3_REGION=eu-central-1
|
|
||||||
export PENPOT_STORAGE_ASSETS_S3_BUCKET=penpot
|
export PENPOT_STORAGE_ASSETS_S3_BUCKET=penpot
|
||||||
|
|
||||||
export OPTIONS="
|
export OPTIONS="
|
||||||
|
|
|
@ -55,54 +55,66 @@
|
||||||
(s/def ::migrations map?)
|
(s/def ::migrations map?)
|
||||||
(s/def ::name keyword?)
|
(s/def ::name keyword?)
|
||||||
(s/def ::password ::us/string)
|
(s/def ::password ::us/string)
|
||||||
(s/def ::read-only ::us/boolean)
|
|
||||||
(s/def ::uri ::us/not-empty-string)
|
(s/def ::uri ::us/not-empty-string)
|
||||||
(s/def ::username ::us/string)
|
(s/def ::username ::us/string)
|
||||||
(s/def ::validation-timeout ::us/integer)
|
(s/def ::validation-timeout ::us/integer)
|
||||||
|
(s/def ::read-only? ::us/boolean)
|
||||||
|
|
||||||
(defmethod ig/pre-init-spec ::pool [_]
|
(s/def ::pool-options
|
||||||
(s/keys :req-un [::uri ::name
|
(s/keys :opt-un [::uri ::name
|
||||||
::min-size
|
::min-size
|
||||||
::max-size
|
::max-size
|
||||||
::connection-timeout
|
::connection-timeout
|
||||||
::validation-timeout]
|
::validation-timeout
|
||||||
:opt-un [::migrations
|
::migrations
|
||||||
::username
|
::username
|
||||||
::password
|
::password
|
||||||
::mtx/metrics
|
::mtx/metrics
|
||||||
::read-only]))
|
::read-only?]))
|
||||||
|
|
||||||
|
(def defaults
|
||||||
|
{:name :main
|
||||||
|
:min-size 0
|
||||||
|
:max-size 30
|
||||||
|
:connection-timeout 10000
|
||||||
|
:validation-timeout 10000
|
||||||
|
:idle-timeout 120000 ; 2min
|
||||||
|
:max-lifetime 1800000 ; 30m
|
||||||
|
:read-only? false})
|
||||||
|
|
||||||
(defmethod ig/prep-key ::pool
|
(defmethod ig/prep-key ::pool
|
||||||
[_ cfg]
|
[_ cfg]
|
||||||
(merge {:name :main
|
(merge defaults (d/without-nils cfg)))
|
||||||
:min-size 0
|
|
||||||
:max-size 30
|
;; Don't validate here, just validate that a map is received.
|
||||||
:connection-timeout 10000
|
(defmethod ig/pre-init-spec ::pool [_] ::pool-options)
|
||||||
:validation-timeout 10000
|
|
||||||
:idle-timeout 120000 ; 2min
|
|
||||||
:max-lifetime 1800000 ; 30m
|
|
||||||
:read-only false}
|
|
||||||
(d/without-nils cfg)))
|
|
||||||
|
|
||||||
(defmethod ig/init-key ::pool
|
(defmethod ig/init-key ::pool
|
||||||
[_ {:keys [migrations name read-only] :as cfg}]
|
[_ {:keys [migrations read-only? uri] :as cfg}]
|
||||||
(l/info :hint "initialize connection pool"
|
(if uri
|
||||||
:name (d/name name)
|
(let [pool (create-pool cfg)]
|
||||||
:uri (:uri cfg)
|
(l/info :hint "initialize connection pool"
|
||||||
:read-only read-only
|
:name (d/name (:name cfg))
|
||||||
:with-credentials (and (contains? cfg :username)
|
:uri uri
|
||||||
(contains? cfg :password))
|
:read-only read-only?
|
||||||
:min-size (:min-size cfg)
|
:with-credentials (and (contains? cfg :username)
|
||||||
:max-size (:max-size cfg))
|
(contains? cfg :password))
|
||||||
|
:min-size (:min-size cfg)
|
||||||
|
:max-size (:max-size cfg))
|
||||||
|
(when-not read-only?
|
||||||
|
(some->> (seq migrations) (apply-migrations! pool)))
|
||||||
|
pool)
|
||||||
|
|
||||||
(let [pool (create-pool cfg)]
|
(do
|
||||||
(when-not read-only
|
(l/warn :hint "unable to initialize pool, missing url"
|
||||||
(some->> (seq migrations) (apply-migrations! pool)))
|
:name (d/name (:name cfg))
|
||||||
pool))
|
:read-only read-only?)
|
||||||
|
nil)))
|
||||||
|
|
||||||
(defmethod ig/halt-key! ::pool
|
(defmethod ig/halt-key! ::pool
|
||||||
[_ pool]
|
[_ pool]
|
||||||
(.close ^HikariDataSource pool))
|
(when pool
|
||||||
|
(.close ^HikariDataSource pool)))
|
||||||
|
|
||||||
(defn- apply-migrations!
|
(defn- apply-migrations!
|
||||||
[pool migrations]
|
[pool migrations]
|
||||||
|
@ -126,7 +138,7 @@
|
||||||
(.setJdbcUrl (str "jdbc:" uri))
|
(.setJdbcUrl (str "jdbc:" uri))
|
||||||
(.setPoolName (d/name (:name cfg)))
|
(.setPoolName (d/name (:name cfg)))
|
||||||
(.setAutoCommit true)
|
(.setAutoCommit true)
|
||||||
(.setReadOnly (:read-only cfg))
|
(.setReadOnly (:read-only? cfg))
|
||||||
(.setConnectionTimeout (:connection-timeout cfg))
|
(.setConnectionTimeout (:connection-timeout cfg))
|
||||||
(.setValidationTimeout (:validation-timeout cfg))
|
(.setValidationTimeout (:validation-timeout cfg))
|
||||||
(.setIdleTimeout (:idle-timeout cfg))
|
(.setIdleTimeout (:idle-timeout cfg))
|
||||||
|
|
|
@ -257,12 +257,16 @@
|
||||||
(ex/raise :type :internal
|
(ex/raise :type :internal
|
||||||
:code :task-not-configured
|
:code :task-not-configured
|
||||||
:hint "archive task not configured, missing uri"))
|
:hint "archive task not configured, missing uri"))
|
||||||
|
|
||||||
(when enabled
|
(when enabled
|
||||||
(loop []
|
(loop [total 0]
|
||||||
(let [res (archive-events cfg)]
|
(let [n (archive-events cfg)]
|
||||||
(when (= res :continue)
|
(if n
|
||||||
(aa/thread-sleep 200)
|
(do
|
||||||
(recur))))))))
|
(aa/thread-sleep 200)
|
||||||
|
(recur (+ total n)))
|
||||||
|
(when (pos? total)
|
||||||
|
(l/trace :hint "events chunk archived" :num total)))))))))
|
||||||
|
|
||||||
(def sql:retrieve-batch-of-audit-log
|
(def sql:retrieve-batch-of-audit-log
|
||||||
"select * from audit_log
|
"select * from audit_log
|
||||||
|
@ -332,7 +336,7 @@
|
||||||
(l/debug :action "archive-events" :uri uri :events (count events))
|
(l/debug :action "archive-events" :uri uri :events (count events))
|
||||||
(when (send events)
|
(when (send events)
|
||||||
(mark-as-archived conn rows)
|
(mark-as-archived conn rows)
|
||||||
:continue))))))
|
(count events)))))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; GC Task
|
;; GC Task
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue