2016-11-20 20:04:52 +01:00
|
|
|
;; 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/.
|
|
|
|
;;
|
2022-09-20 23:23:22 +02:00
|
|
|
;; Copyright (c) KALEIDOS INC
|
2016-11-20 20:04:52 +01:00
|
|
|
|
2020-08-18 19:26:37 +02:00
|
|
|
(ns app.main
|
2020-01-23 17:53:26 +01:00
|
|
|
(:require
|
2022-11-28 16:48:30 +01:00
|
|
|
[app.auth.oidc :as-alias oidc]
|
|
|
|
[app.auth.oidc.providers :as-alias oidc.providers]
|
2021-09-29 16:39:25 +02:00
|
|
|
[app.common.logging :as l]
|
2021-03-30 14:55:19 +02:00
|
|
|
[app.config :as cf]
|
2022-11-22 18:06:24 +01:00
|
|
|
[app.db :as-alias db]
|
2022-11-28 16:48:30 +01:00
|
|
|
[app.http.client :as-alias http.client]
|
|
|
|
[app.http.session :as-alias http.session]
|
|
|
|
[app.loggers.audit :as-alias audit]
|
|
|
|
[app.loggers.audit.tasks :as-alias audit.tasks]
|
2022-12-07 14:47:32 +01:00
|
|
|
[app.loggers.webhooks :as-alias webhooks]
|
2022-11-28 16:48:30 +01:00
|
|
|
[app.loggers.zmq :as-alias lzmq]
|
2022-11-22 18:06:24 +01:00
|
|
|
[app.metrics :as-alias mtx]
|
2022-11-07 11:18:22 +01:00
|
|
|
[app.metrics.definition :as-alias mdef]
|
2022-11-22 18:06:24 +01:00
|
|
|
[app.redis :as-alias rds]
|
|
|
|
[app.storage :as-alias sto]
|
2020-12-24 14:32:19 +01:00
|
|
|
[app.util.time :as dt]
|
2022-11-22 18:06:24 +01:00
|
|
|
[app.worker :as-alias wrk]
|
2022-09-21 00:46:22 +02:00
|
|
|
[cuerdas.core :as str]
|
2022-01-11 16:30:22 +01:00
|
|
|
[integrant.core :as ig])
|
|
|
|
(:gen-class))
|
2020-01-31 19:12:58 +01:00
|
|
|
|
2022-11-07 11:18:22 +01:00
|
|
|
(def default-metrics
|
|
|
|
{:update-file-changes
|
|
|
|
{::mdef/name "penpot_rpc_update_file_changes_total"
|
|
|
|
::mdef/help "A total number of changes submitted to update-file."
|
|
|
|
::mdef/type :counter}
|
|
|
|
|
|
|
|
:update-file-bytes-processed
|
|
|
|
{::mdef/name "penpot_rpc_update_file_bytes_processed_total"
|
|
|
|
::mdef/help "A total number of bytes processed by update-file."
|
|
|
|
::mdef/type :counter}
|
|
|
|
|
|
|
|
:rpc-mutation-timing
|
|
|
|
{::mdef/name "penpot_rpc_mutation_timing"
|
|
|
|
::mdef/help "RPC mutation method call timing."
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :histogram}
|
|
|
|
|
|
|
|
:rpc-command-timing
|
|
|
|
{::mdef/name "penpot_rpc_command_timing"
|
|
|
|
::mdef/help "RPC command method call timing."
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :histogram}
|
|
|
|
|
|
|
|
:rpc-query-timing
|
|
|
|
{::mdef/name "penpot_rpc_query_timing"
|
|
|
|
::mdef/help "RPC query method call timing."
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :histogram}
|
|
|
|
|
|
|
|
:websocket-active-connections
|
|
|
|
{::mdef/name "penpot_websocket_active_connections"
|
|
|
|
::mdef/help "Active websocket connections gauge"
|
|
|
|
::mdef/type :gauge}
|
|
|
|
|
|
|
|
:websocket-messages-total
|
|
|
|
{::mdef/name "penpot_websocket_message_total"
|
|
|
|
::mdef/help "Counter of processed messages."
|
|
|
|
::mdef/labels ["op"]
|
|
|
|
::mdef/type :counter}
|
|
|
|
|
|
|
|
:websocket-session-timing
|
|
|
|
{::mdef/name "penpot_websocket_session_timing"
|
|
|
|
::mdef/help "Websocket session timing (seconds)."
|
|
|
|
::mdef/type :summary}
|
|
|
|
|
|
|
|
:session-update-total
|
|
|
|
{::mdef/name "penpot_http_session_update_total"
|
|
|
|
::mdef/help "A counter of session update batch events."
|
|
|
|
::mdef/type :counter}
|
|
|
|
|
|
|
|
:tasks-timing
|
|
|
|
{::mdef/name "penpot_tasks_timing"
|
|
|
|
::mdef/help "Background tasks timing (milliseconds)."
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :summary}
|
|
|
|
|
|
|
|
:redis-eval-timing
|
|
|
|
{::mdef/name "penpot_redis_eval_timing"
|
|
|
|
::mdef/help "Redis EVAL commands execution timings (ms)"
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :summary}
|
|
|
|
|
|
|
|
:rpc-climit-queue-size
|
|
|
|
{::mdef/name "penpot_rpc_climit_queue_size"
|
|
|
|
::mdef/help "Current number of queued submissions on the CLIMIT."
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :gauge}
|
|
|
|
|
|
|
|
:rpc-climit-concurrency
|
|
|
|
{::mdef/name "penpot_rpc_climit_concurrency"
|
|
|
|
::mdef/help "Current number of used concurrency capacity on the CLIMIT"
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :gauge}
|
|
|
|
|
|
|
|
:rpc-climit-timing
|
|
|
|
{::mdef/name "penpot_rpc_climit_timing"
|
|
|
|
::mdef/help "Summary of the time between queuing and executing on the CLIMIT"
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :summary}
|
|
|
|
|
2022-11-28 16:48:30 +01:00
|
|
|
:audit-http-handler-queue-size
|
|
|
|
{::mdef/name "penpot_audit_http_handler_queue_size"
|
|
|
|
::mdef/help "Current number of queued submissions on the audit log http handler"
|
|
|
|
::mdef/labels []
|
|
|
|
::mdef/type :gauge}
|
|
|
|
|
|
|
|
:audit-http-handler-concurrency
|
|
|
|
{::mdef/name "penpot_audit_http_handler_concurrency"
|
|
|
|
::mdef/help "Current number of used concurrency capacity on the audit log http handler"
|
|
|
|
::mdef/labels []
|
|
|
|
::mdef/type :gauge}
|
|
|
|
|
|
|
|
:audit-http-handler-timing
|
|
|
|
{::mdef/name "penpot_audit_http_handler_timing"
|
|
|
|
::mdef/help "Summary of the time between queuing and executing on the audit log http handler"
|
|
|
|
::mdef/labels []
|
|
|
|
::mdef/type :summary}
|
|
|
|
|
2022-11-07 11:18:22 +01:00
|
|
|
:executors-active-threads
|
|
|
|
{::mdef/name "penpot_executors_active_threads"
|
|
|
|
::mdef/help "Current number of threads available in the executor service."
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :gauge}
|
|
|
|
|
|
|
|
:executors-completed-tasks
|
|
|
|
{::mdef/name "penpot_executors_completed_tasks_total"
|
|
|
|
::mdef/help "Approximate number of completed tasks by the executor."
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :counter}
|
|
|
|
|
|
|
|
:executors-running-threads
|
|
|
|
{::mdef/name "penpot_executors_running_threads"
|
|
|
|
::mdef/help "Current number of threads with state RUNNING."
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :gauge}
|
|
|
|
|
|
|
|
:executors-queued-submissions
|
|
|
|
{::mdef/name "penpot_executors_queued_submissions"
|
|
|
|
::mdef/help "Current number of queued submissions."
|
|
|
|
::mdef/labels ["name"]
|
|
|
|
::mdef/type :gauge}})
|
|
|
|
|
2021-03-30 14:55:19 +02:00
|
|
|
(def system-config
|
2022-11-22 18:06:24 +01:00
|
|
|
{::db/pool
|
2021-03-30 14:55:19 +02:00
|
|
|
{:uri (cf/get :database-uri)
|
|
|
|
:username (cf/get :database-username)
|
|
|
|
:password (cf/get :database-password)
|
2022-01-27 14:02:37 +01:00
|
|
|
:read-only (cf/get :database-readonly false)
|
2022-11-22 18:06:24 +01:00
|
|
|
:metrics (ig/ref ::mtx/metrics)
|
2021-03-30 14:55:19 +02:00
|
|
|
:migrations (ig/ref :app.migrations/all)
|
2022-04-01 15:55:28 +02:00
|
|
|
:name :main
|
|
|
|
:min-size (cf/get :database-min-pool-size 0)
|
2022-09-17 10:46:35 +02:00
|
|
|
:max-size (cf/get :database-max-pool-size 60)}
|
2022-02-18 18:01:21 +01:00
|
|
|
|
|
|
|
;; Default thread pool for IO operations
|
2022-11-22 18:06:24 +01:00
|
|
|
::wrk/executor
|
|
|
|
{::wrk/parallelism (cf/get :default-executor-parallelism 100)}
|
2022-02-18 18:01:21 +01:00
|
|
|
|
2022-11-22 18:06:24 +01:00
|
|
|
::wrk/scheduled-executor
|
|
|
|
{::wrk/parallelism (cf/get :scheduled-executor-parallelism 20)}
|
2022-02-18 18:01:21 +01:00
|
|
|
|
2022-11-22 18:06:24 +01:00
|
|
|
::wrk/monitor
|
|
|
|
{::mtx/metrics (ig/ref ::mtx/metrics)
|
|
|
|
::wrk/name "default"
|
|
|
|
::wrk/executor (ig/ref ::wrk/executor)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2021-12-28 00:04:58 +01:00
|
|
|
:app.migrations/migrations
|
|
|
|
{}
|
|
|
|
|
2022-11-22 18:06:24 +01:00
|
|
|
::mtx/metrics
|
2022-11-07 11:18:22 +01:00
|
|
|
{:default default-metrics}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
|
|
|
:app.migrations/all
|
|
|
|
{:main (ig/ref :app.migrations/migrations)}
|
|
|
|
|
2022-11-22 18:06:24 +01:00
|
|
|
::rds/redis
|
|
|
|
{::rds/uri (cf/get :redis-uri)
|
|
|
|
::mtx/metrics (ig/ref ::mtx/metrics)}
|
2022-08-30 14:26:54 +02:00
|
|
|
|
2021-03-30 14:55:19 +02:00
|
|
|
:app.msgbus/msgbus
|
|
|
|
{:backend (cf/get :msgbus-backend :redis)
|
2022-11-22 18:06:24 +01:00
|
|
|
:executor (ig/ref ::wrk/executor)
|
|
|
|
:redis (ig/ref ::rds/redis)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2022-06-22 11:34:36 +02:00
|
|
|
:app.storage.tmp/cleaner
|
2022-11-23 23:45:10 +01:00
|
|
|
{::wrk/executor (ig/ref ::wrk/executor)
|
|
|
|
::wrk/scheduled-executor (ig/ref ::wrk/scheduled-executor)}
|
2022-06-22 11:34:36 +02:00
|
|
|
|
2022-11-22 18:06:24 +01:00
|
|
|
::sto/gc-deleted-task
|
|
|
|
{:pool (ig/ref ::db/pool)
|
|
|
|
:storage (ig/ref ::sto/storage)
|
|
|
|
:executor (ig/ref ::wrk/executor)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2022-11-22 18:06:24 +01:00
|
|
|
::sto/gc-touched-task
|
|
|
|
{:pool (ig/ref ::db/pool)}
|
2022-02-28 17:15:58 +01:00
|
|
|
|
2022-11-28 16:48:30 +01:00
|
|
|
::http.client/client
|
|
|
|
{::wrk/executor (ig/ref ::wrk/executor)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2022-10-14 13:53:31 +02:00
|
|
|
:app.http.session/manager
|
2022-11-22 18:06:24 +01:00
|
|
|
{:pool (ig/ref ::db/pool)
|
2022-08-24 13:44:33 +02:00
|
|
|
:sprops (ig/ref :app.setup/props)
|
2022-11-22 18:06:24 +01:00
|
|
|
:executor (ig/ref ::wrk/executor)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
|
|
|
:app.http.session/gc-task
|
2022-11-22 18:06:24 +01:00
|
|
|
{:pool (ig/ref ::db/pool)
|
2022-08-04 22:50:02 +02:00
|
|
|
:max-age (cf/get :auth-token-cookie-max-age)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
|
|
|
:app.http.awsns/handler
|
2022-11-28 16:48:30 +01:00
|
|
|
{::props (ig/ref :app.setup/props)
|
|
|
|
::db/pool (ig/ref ::db/pool)
|
|
|
|
::http.client/client (ig/ref ::http.client/client)
|
|
|
|
::wrk/executor (ig/ref ::wrk/executor)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
|
|
|
:app.http/server
|
2022-02-18 18:01:21 +01:00
|
|
|
{:port (cf/get :http-server-port)
|
|
|
|
:host (cf/get :http-server-host)
|
|
|
|
:router (ig/ref :app.http/router)
|
2022-11-22 18:06:24 +01:00
|
|
|
:metrics (ig/ref ::mtx/metrics)
|
|
|
|
:executor (ig/ref ::wrk/executor)
|
2022-04-01 13:33:56 +02:00
|
|
|
:io-threads (cf/get :http-server-io-threads)
|
|
|
|
:max-body-size (cf/get :http-server-max-body-size)
|
|
|
|
:max-multipart-body-size (cf/get :http-server-max-multipart-body-size)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2022-06-30 15:11:41 +02:00
|
|
|
:app.auth.ldap/provider
|
|
|
|
{:host (cf/get :ldap-host)
|
|
|
|
:port (cf/get :ldap-port)
|
|
|
|
:ssl (cf/get :ldap-ssl)
|
|
|
|
:tls (cf/get :ldap-starttls)
|
|
|
|
:query (cf/get :ldap-user-query)
|
|
|
|
:attrs-email (cf/get :ldap-attrs-email)
|
|
|
|
:attrs-fullname (cf/get :ldap-attrs-fullname)
|
|
|
|
:attrs-username (cf/get :ldap-attrs-username)
|
|
|
|
:base-dn (cf/get :ldap-base-dn)
|
|
|
|
:bind-dn (cf/get :ldap-bind-dn)
|
|
|
|
:bind-password (cf/get :ldap-bind-password)
|
|
|
|
:enabled? (contains? cf/flags :login-with-ldap)}
|
|
|
|
|
2022-11-28 16:48:30 +01:00
|
|
|
::oidc.providers/google
|
|
|
|
{}
|
|
|
|
|
|
|
|
::oidc.providers/github
|
|
|
|
{::http.client/client (ig/ref ::http.client/client)}
|
|
|
|
|
|
|
|
::oidc.providers/gitlab
|
|
|
|
{}
|
|
|
|
|
|
|
|
::oidc.providers/generic
|
|
|
|
{::http.client/client (ig/ref ::http.client/client)}
|
|
|
|
|
|
|
|
::oidc/routes
|
|
|
|
{::http.client/client (ig/ref ::http.client/client)
|
|
|
|
::db/pool (ig/ref ::db/pool)
|
|
|
|
::props (ig/ref :app.setup/props)
|
|
|
|
::wrk/executor (ig/ref ::wrk/executor)
|
|
|
|
::oidc/providers {:google (ig/ref ::oidc.providers/google)
|
|
|
|
:github (ig/ref ::oidc.providers/github)
|
|
|
|
:gitlab (ig/ref ::oidc.providers/gitlab)
|
|
|
|
:oidc (ig/ref ::oidc.providers/generic)}
|
|
|
|
::audit/collector (ig/ref ::audit/collector)
|
|
|
|
::http.session/session (ig/ref :app.http.session/manager)}
|
|
|
|
|
2022-06-30 15:11:41 +02:00
|
|
|
|
2022-08-24 13:44:33 +02:00
|
|
|
;; TODO: revisit the dependencies of this service, looks they are too much unused of them
|
2021-03-30 14:55:19 +02:00
|
|
|
:app.http/router
|
2022-02-28 17:15:58 +01:00
|
|
|
{:assets (ig/ref :app.http.assets/handlers)
|
|
|
|
:feedback (ig/ref :app.http.feedback/handler)
|
2022-10-14 13:53:31 +02:00
|
|
|
:session (ig/ref :app.http.session/manager)
|
2022-02-28 17:15:58 +01:00
|
|
|
:awsns-handler (ig/ref :app.http.awsns/handler)
|
2022-06-22 11:42:23 +02:00
|
|
|
:debug-routes (ig/ref :app.http.debug/routes)
|
2022-11-28 16:48:30 +01:00
|
|
|
:oidc-routes (ig/ref ::oidc/routes)
|
2022-02-28 17:15:58 +01:00
|
|
|
:ws (ig/ref :app.http.websocket/handler)
|
2022-11-22 18:06:24 +01:00
|
|
|
:metrics (ig/ref ::mtx/metrics)
|
2022-02-28 17:15:58 +01:00
|
|
|
:public-uri (cf/get :public-uri)
|
2022-11-22 18:06:24 +01:00
|
|
|
:storage (ig/ref ::sto/storage)
|
2022-06-30 15:11:41 +02:00
|
|
|
:rpc-routes (ig/ref :app.rpc/routes)
|
2022-07-13 14:29:34 +02:00
|
|
|
:doc-routes (ig/ref :app.rpc.doc/routes)
|
2022-11-22 18:06:24 +01:00
|
|
|
:executor (ig/ref ::wrk/executor)}
|
2021-12-28 00:04:58 +01:00
|
|
|
|
2022-06-22 11:42:23 +02:00
|
|
|
:app.http.debug/routes
|
2022-11-22 18:06:24 +01:00
|
|
|
{:pool (ig/ref ::db/pool)
|
|
|
|
:executor (ig/ref ::wrk/executor)
|
|
|
|
:storage (ig/ref ::sto/storage)
|
2022-10-14 13:53:31 +02:00
|
|
|
:session (ig/ref :app.http.session/manager)}
|
2021-12-30 11:36:48 +01:00
|
|
|
|
2021-12-28 00:04:58 +01:00
|
|
|
:app.http.websocket/handler
|
2022-11-22 18:06:24 +01:00
|
|
|
{:pool (ig/ref ::db/pool)
|
|
|
|
:metrics (ig/ref ::mtx/metrics)
|
2021-12-28 00:04:58 +01:00
|
|
|
:msgbus (ig/ref :app.msgbus/msgbus)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
|
|
|
:app.http.assets/handlers
|
2022-11-22 18:06:24 +01:00
|
|
|
{:metrics (ig/ref ::mtx/metrics)
|
2021-03-30 14:55:19 +02:00
|
|
|
:assets-path (cf/get :assets-path)
|
2022-11-22 18:06:24 +01:00
|
|
|
:storage (ig/ref ::sto/storage)
|
|
|
|
:executor (ig/ref ::wrk/executor)
|
2021-03-30 14:55:19 +02:00
|
|
|
:cache-max-age (dt/duration {:hours 24})
|
|
|
|
:signature-max-age (dt/duration {:hours 24 :minutes 5})}
|
|
|
|
|
|
|
|
:app.http.feedback/handler
|
2022-11-22 18:06:24 +01:00
|
|
|
{:pool (ig/ref ::db/pool)
|
|
|
|
:executor (ig/ref ::wrk/executor)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2022-10-16 23:44:16 +02:00
|
|
|
:app.rpc/climit
|
2022-11-22 18:06:24 +01:00
|
|
|
{:metrics (ig/ref ::mtx/metrics)
|
|
|
|
:executor (ig/ref ::wrk/executor)}
|
2022-09-19 12:25:44 +02:00
|
|
|
|
2022-09-01 08:38:17 +02:00
|
|
|
:app.rpc/rlimit
|
2022-11-22 18:06:24 +01:00
|
|
|
{:executor (ig/ref ::wrk/executor)
|
|
|
|
:scheduled-executor (ig/ref ::wrk/scheduled-executor)}
|
2022-09-01 08:38:17 +02:00
|
|
|
|
2022-06-30 15:11:41 +02:00
|
|
|
:app.rpc/methods
|
2022-11-28 16:48:30 +01:00
|
|
|
{::audit/collector (ig/ref ::audit/collector)
|
|
|
|
::http.client/client (ig/ref ::http.client/client)
|
2022-11-30 15:38:48 +01:00
|
|
|
::db/pool (ig/ref ::db/pool)
|
|
|
|
::wrk/executor (ig/ref ::wrk/executor)
|
|
|
|
|
|
|
|
:pool (ig/ref ::db/pool)
|
|
|
|
:session (ig/ref :app.http.session/manager)
|
|
|
|
:sprops (ig/ref :app.setup/props)
|
|
|
|
:metrics (ig/ref ::mtx/metrics)
|
|
|
|
:storage (ig/ref ::sto/storage)
|
|
|
|
:msgbus (ig/ref :app.msgbus/msgbus)
|
|
|
|
:public-uri (cf/get :public-uri)
|
|
|
|
:redis (ig/ref ::rds/redis)
|
|
|
|
:ldap (ig/ref :app.auth.ldap/provider)
|
|
|
|
:http-client (ig/ref ::http.client/client)
|
|
|
|
:climit (ig/ref :app.rpc/climit)
|
|
|
|
:rlimit (ig/ref :app.rpc/rlimit)
|
|
|
|
:executor (ig/ref ::wrk/executor)
|
|
|
|
:templates (ig/ref :app.setup/builtin-templates)
|
2022-09-19 12:25:44 +02:00
|
|
|
}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2022-07-13 14:29:34 +02:00
|
|
|
:app.rpc.doc/routes
|
|
|
|
{:methods (ig/ref :app.rpc/methods)}
|
|
|
|
|
2022-06-30 15:11:41 +02:00
|
|
|
:app.rpc/routes
|
|
|
|
{:methods (ig/ref :app.rpc/methods)}
|
|
|
|
|
2022-11-22 18:06:24 +01:00
|
|
|
::wrk/registry
|
|
|
|
{:metrics (ig/ref ::mtx/metrics)
|
2021-03-30 14:55:19 +02:00
|
|
|
:tasks
|
2022-09-20 13:41:18 +02:00
|
|
|
{:sendmail (ig/ref :app.emails/handler)
|
2021-06-07 16:51:09 +02:00
|
|
|
:objects-gc (ig/ref :app.tasks.objects-gc/handler)
|
2022-03-23 10:59:20 +01:00
|
|
|
:file-gc (ig/ref :app.tasks.file-gc/handler)
|
2021-03-30 14:55:19 +02:00
|
|
|
:file-xlog-gc (ig/ref :app.tasks.file-xlog-gc/handler)
|
2022-11-22 18:06:24 +01:00
|
|
|
:storage-gc-deleted (ig/ref ::sto/gc-deleted-task)
|
|
|
|
:storage-gc-touched (ig/ref ::sto/gc-touched-task)
|
2021-03-30 14:55:19 +02:00
|
|
|
:tasks-gc (ig/ref :app.tasks.tasks-gc/handler)
|
|
|
|
:telemetry (ig/ref :app.tasks.telemetry/handler)
|
2021-05-14 12:38:28 +02:00
|
|
|
:session-gc (ig/ref :app.http.session/gc-task)
|
2022-11-28 16:48:30 +01:00
|
|
|
:audit-log-archive (ig/ref ::audit.tasks/archive)
|
2022-12-07 14:47:32 +01:00
|
|
|
:audit-log-gc (ig/ref ::audit.tasks/gc)
|
|
|
|
|
|
|
|
:process-webhook-event
|
|
|
|
(ig/ref ::webhooks/process-event-handler)
|
|
|
|
:run-webhook
|
|
|
|
(ig/ref ::webhooks/run-webhook-handler)}}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2022-09-20 13:41:18 +02:00
|
|
|
|
|
|
|
:app.emails/sendmail
|
2021-03-30 14:55:19 +02:00
|
|
|
{:host (cf/get :smtp-host)
|
|
|
|
:port (cf/get :smtp-port)
|
|
|
|
:ssl (cf/get :smtp-ssl)
|
|
|
|
:tls (cf/get :smtp-tls)
|
|
|
|
:username (cf/get :smtp-username)
|
|
|
|
:password (cf/get :smtp-password)
|
|
|
|
:default-reply-to (cf/get :smtp-default-reply-to)
|
|
|
|
:default-from (cf/get :smtp-default-from)}
|
|
|
|
|
2022-09-20 13:41:18 +02:00
|
|
|
:app.emails/handler
|
|
|
|
{:sendmail (ig/ref :app.emails/sendmail)
|
2022-11-22 18:06:24 +01:00
|
|
|
:metrics (ig/ref ::mtx/metrics)}
|
2022-09-20 13:41:18 +02:00
|
|
|
|
2021-03-30 14:55:19 +02:00
|
|
|
:app.tasks.tasks-gc/handler
|
2022-11-22 18:06:24 +01:00
|
|
|
{:pool (ig/ref ::db/pool)
|
2021-06-03 12:55:31 +02:00
|
|
|
:max-age cf/deletion-delay}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2021-06-07 16:51:09 +02:00
|
|
|
:app.tasks.objects-gc/handler
|
2022-11-22 18:06:24 +01:00
|
|
|
{:pool (ig/ref ::db/pool)
|
|
|
|
:storage (ig/ref ::sto/storage)}
|
2021-06-07 16:51:09 +02:00
|
|
|
|
2022-03-23 10:59:20 +01:00
|
|
|
:app.tasks.file-gc/handler
|
2022-11-22 18:06:24 +01:00
|
|
|
{:pool (ig/ref ::db/pool)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
|
|
|
:app.tasks.file-xlog-gc/handler
|
2022-11-22 18:06:24 +01:00
|
|
|
{:pool (ig/ref ::db/pool)}
|
2021-06-14 11:50:26 +02:00
|
|
|
|
2021-03-30 14:55:19 +02:00
|
|
|
:app.tasks.telemetry/handler
|
2022-11-28 16:48:30 +01:00
|
|
|
{::db/pool (ig/ref ::db/pool)
|
|
|
|
::http.client/client (ig/ref ::http.client/client)
|
|
|
|
::props (ig/ref :app.setup/props)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
|
|
|
:app.srepl/server
|
|
|
|
{:port (cf/get :srepl-port)
|
|
|
|
:host (cf/get :srepl-host)}
|
|
|
|
|
2022-07-28 15:11:50 +02:00
|
|
|
:app.setup/builtin-templates
|
2022-11-28 16:48:30 +01:00
|
|
|
{::http.client/client (ig/ref ::http.client/client)}
|
2022-07-28 15:11:50 +02:00
|
|
|
|
2021-03-30 14:55:19 +02:00
|
|
|
:app.setup/props
|
2022-11-22 18:06:24 +01:00
|
|
|
{:pool (ig/ref ::db/pool)
|
2021-05-04 15:12:42 +02:00
|
|
|
:key (cf/get :secret-key)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2022-11-28 16:48:30 +01:00
|
|
|
::lzmq/receiver
|
|
|
|
{}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2022-11-28 16:48:30 +01:00
|
|
|
::audit/collector
|
|
|
|
{::db/pool (ig/ref ::db/pool)
|
|
|
|
::wrk/executor (ig/ref ::wrk/executor)
|
|
|
|
::mtx/metrics (ig/ref ::mtx/metrics)}
|
2021-05-09 14:06:27 +02:00
|
|
|
|
2022-11-28 16:48:30 +01:00
|
|
|
::audit.tasks/archive
|
|
|
|
{::props (ig/ref :app.setup/props)
|
|
|
|
::db/pool (ig/ref ::db/pool)
|
|
|
|
::http.client/client (ig/ref ::http.client/client)}
|
2021-05-14 12:38:28 +02:00
|
|
|
|
2022-11-28 16:48:30 +01:00
|
|
|
::audit.tasks/gc
|
|
|
|
{::db/pool (ig/ref ::db/pool)}
|
2021-05-14 12:38:28 +02:00
|
|
|
|
2022-12-07 14:47:32 +01:00
|
|
|
::webhooks/process-event-handler
|
|
|
|
{::db/pool (ig/ref ::db/pool)
|
|
|
|
::http.client/client (ig/ref ::http.client/client)}
|
|
|
|
|
|
|
|
::webhooks/run-webhook-handler
|
|
|
|
{::db/pool (ig/ref ::db/pool)
|
|
|
|
::http.client/client (ig/ref ::http.client/client)}
|
|
|
|
|
2021-03-30 14:55:19 +02:00
|
|
|
:app.loggers.loki/reporter
|
2022-11-28 16:48:30 +01:00
|
|
|
{::lzmq/receiver (ig/ref ::lzmq/receiver)
|
|
|
|
::http.client/client (ig/ref ::http.client/client)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
|
|
|
:app.loggers.mattermost/reporter
|
2022-11-28 16:48:30 +01:00
|
|
|
{::lzmq/receiver (ig/ref ::lzmq/receiver)
|
|
|
|
::http.client/client (ig/ref ::http.client/client)}
|
2021-03-30 14:55:19 +02:00
|
|
|
|
2021-09-15 14:10:43 +02:00
|
|
|
:app.loggers.database/reporter
|
|
|
|
{:receiver (ig/ref :app.loggers.zmq/receiver)
|
2022-11-22 18:06:24 +01:00
|
|
|
:pool (ig/ref ::db/pool)
|
|
|
|
:executor (ig/ref ::wrk/executor)}
|
2021-09-15 14:10:43 +02:00
|
|
|
|
2022-11-22 18:06:24 +01:00
|
|
|
::sto/storage
|
|
|
|
{:pool (ig/ref ::db/pool)
|
|
|
|
:executor (ig/ref ::wrk/executor)
|
2022-02-28 17:15:58 +01:00
|
|
|
|
2022-02-10 19:50:40 +01:00
|
|
|
:backends
|
|
|
|
{:assets-s3 (ig/ref [::assets :app.storage.s3/backend])
|
|
|
|
:assets-fs (ig/ref [::assets :app.storage.fs/backend])
|
2021-07-29 12:34:17 +02:00
|
|
|
|
2022-02-10 19:50:40 +01:00
|
|
|
;; keep this for backward compatibility
|
|
|
|
:s3 (ig/ref [::assets :app.storage.s3/backend])
|
|
|
|
:fs (ig/ref [::assets :app.storage.fs/backend])}}
|
2021-06-14 11:50:26 +02:00
|
|
|
|
|
|
|
[::assets :app.storage.s3/backend]
|
2022-02-12 12:14:55 +01:00
|
|
|
{:region (cf/get :storage-assets-s3-region)
|
|
|
|
:endpoint (cf/get :storage-assets-s3-endpoint)
|
2022-02-28 17:15:58 +01:00
|
|
|
:bucket (cf/get :storage-assets-s3-bucket)
|
2022-11-22 18:06:24 +01:00
|
|
|
:executor (ig/ref ::wrk/executor)}
|
2021-06-14 11:50:26 +02:00
|
|
|
|
|
|
|
[::assets :app.storage.fs/backend]
|
|
|
|
{:directory (cf/get :storage-assets-fs-directory)}
|
2022-06-22 11:34:36 +02:00
|
|
|
})
|
2020-12-27 22:47:31 +01:00
|
|
|
|
2022-08-12 08:52:36 +02:00
|
|
|
|
|
|
|
(def worker-config
|
2022-11-22 18:06:24 +01:00
|
|
|
{::wrk/cron
|
|
|
|
{::wrk/scheduled-executor (ig/ref ::wrk/scheduled-executor)
|
|
|
|
::wrk/registry (ig/ref ::wrk/registry)
|
|
|
|
::db/pool (ig/ref ::db/pool)
|
|
|
|
::wrk/entries
|
2022-09-06 12:17:28 +02:00
|
|
|
[{:cron #app/cron "0 0 * * * ?" ;; hourly
|
2022-08-12 08:52:36 +02:00
|
|
|
:task :file-xlog-gc}
|
|
|
|
|
2022-09-06 12:17:28 +02:00
|
|
|
{:cron #app/cron "0 0 0 * * ?" ;; daily
|
2022-08-12 08:52:36 +02:00
|
|
|
:task :session-gc}
|
|
|
|
|
2022-09-06 12:17:28 +02:00
|
|
|
{:cron #app/cron "0 0 0 * * ?" ;; daily
|
2022-08-12 08:52:36 +02:00
|
|
|
:task :objects-gc}
|
|
|
|
|
2022-09-06 12:17:28 +02:00
|
|
|
{:cron #app/cron "0 0 0 * * ?" ;; daily
|
|
|
|
:task :storage-gc-deleted}
|
|
|
|
|
|
|
|
{:cron #app/cron "0 0 0 * * ?" ;; daily
|
|
|
|
:task :storage-gc-touched}
|
|
|
|
|
|
|
|
{:cron #app/cron "0 0 0 * * ?" ;; daily
|
2022-08-12 08:52:36 +02:00
|
|
|
:task :tasks-gc}
|
|
|
|
|
2022-09-06 12:17:28 +02:00
|
|
|
{:cron #app/cron "0 0 2 * * ?" ;; daily
|
|
|
|
:task :file-gc}
|
|
|
|
|
2022-08-12 08:52:36 +02:00
|
|
|
{:cron #app/cron "0 30 */3,23 * * ?"
|
|
|
|
:task :telemetry}
|
|
|
|
|
|
|
|
(when (contains? cf/flags :audit-log-archive)
|
|
|
|
{:cron #app/cron "0 */5 * * * ?" ;; every 5m
|
|
|
|
:task :audit-log-archive})
|
|
|
|
|
|
|
|
(when (contains? cf/flags :audit-log-gc)
|
2022-09-17 10:30:00 +02:00
|
|
|
{:cron #app/cron "30 */5 * * * ?" ;; every 5m
|
2022-08-12 08:52:36 +02:00
|
|
|
:task :audit-log-gc})]}
|
|
|
|
|
2022-12-05 23:01:53 +01:00
|
|
|
::wrk/dispatcher
|
2022-11-22 18:06:24 +01:00
|
|
|
{::rds/redis (ig/ref ::rds/redis)
|
|
|
|
::mtx/metrics (ig/ref ::mtx/metrics)
|
|
|
|
::db/pool (ig/ref ::db/pool)}
|
|
|
|
|
2022-12-05 23:01:53 +01:00
|
|
|
[::default ::wrk/worker]
|
|
|
|
{::wrk/parallelism (cf/get ::worker-default-parallelism 1)
|
|
|
|
::wrk/queue :default
|
|
|
|
::rds/redis (ig/ref ::rds/redis)
|
|
|
|
::wrk/registry (ig/ref ::wrk/registry)
|
|
|
|
::mtx/metrics (ig/ref ::mtx/metrics)
|
|
|
|
::db/pool (ig/ref ::db/pool)}
|
|
|
|
|
|
|
|
[::webhook ::wrk/worker]
|
|
|
|
{::wrk/parallelism (cf/get ::worker-webhook-parallelism 1)
|
|
|
|
::wrk/queue :webhooks
|
2022-11-22 18:06:24 +01:00
|
|
|
::rds/redis (ig/ref ::rds/redis)
|
|
|
|
::wrk/registry (ig/ref ::wrk/registry)
|
|
|
|
::mtx/metrics (ig/ref ::mtx/metrics)
|
|
|
|
::db/pool (ig/ref ::db/pool)}})
|
2022-08-12 08:52:36 +02:00
|
|
|
|
2022-12-05 23:01:53 +01:00
|
|
|
|
2021-01-05 12:31:16 +01:00
|
|
|
(def system nil)
|
2020-12-24 14:32:19 +01:00
|
|
|
|
|
|
|
(defn start
|
|
|
|
[]
|
2022-08-12 08:52:36 +02:00
|
|
|
(ig/load-namespaces (merge system-config worker-config))
|
2021-03-30 14:55:19 +02:00
|
|
|
(alter-var-root #'system (fn [sys]
|
|
|
|
(when sys (ig/halt! sys))
|
|
|
|
(-> system-config
|
2022-08-12 08:52:36 +02:00
|
|
|
(cond-> (contains? cf/flags :backend-worker)
|
|
|
|
(merge worker-config))
|
2021-03-30 14:55:19 +02:00
|
|
|
(ig/prep)
|
|
|
|
(ig/init))))
|
2022-11-28 16:48:30 +01:00
|
|
|
(l/info :hint "welcome to penpot"
|
2022-09-21 00:46:22 +02:00
|
|
|
:flags (str/join "," (map name cf/flags))
|
2022-09-14 12:39:20 +02:00
|
|
|
:worker? (contains? cf/flags :backend-worker)
|
2021-04-06 23:25:34 +02:00
|
|
|
:version (:full cf/version)))
|
2020-12-24 14:32:19 +01:00
|
|
|
|
|
|
|
(defn stop
|
|
|
|
[]
|
|
|
|
(alter-var-root #'system (fn [sys]
|
|
|
|
(when sys (ig/halt! sys))
|
|
|
|
nil)))
|
2020-08-18 18:46:39 +02:00
|
|
|
|
|
|
|
(defn -main
|
2020-12-02 12:36:08 +01:00
|
|
|
[& _args]
|
2022-11-28 16:47:27 +01:00
|
|
|
(try
|
|
|
|
(start)
|
|
|
|
(catch Throwable cause
|
|
|
|
(l/error :hint (ex-message cause)
|
|
|
|
:cause cause)
|
|
|
|
(System/exit -1))))
|