0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 06:58:58 -05:00

🐛 Fix worker configuration initialization.

This commit is contained in:
Andrey Antukh 2020-05-12 13:03:49 +02:00
parent c3a5156a6c
commit d67dbcf2aa
8 changed files with 50 additions and 17 deletions

View file

@ -95,6 +95,7 @@ function readLocales() {
function readConfig(data) {
const publicURL = process.env.UXBOX_PUBLIC_URL;
const backendURL = process.env.UXBOX_BACKEND_URL;
const demoWarn = process.env.UXBOX_DEMO_WARNING;
const deployDate = process.env.UXBOX_DEPLOY_DATE;
const deployCommit = process.env.UXBOX_DEPLOY_COMMIT;
@ -107,6 +108,10 @@ function readConfig(data) {
cfg.publicURL = publicURL;
}
if (backendURL !== undefined) {
cfg.backendURL = backendURL;
}
if (deployDate !== undefined) {
cfg.deployDate = deployDate;
}

View file

@ -12,9 +12,12 @@
(this-as global
(let [config (obj/get global "uxboxConfig")
url (obj/get config "publicURL" "http://localhost:6060")
purl (obj/get config "publicURL" "http://localhost:3449")
burl (obj/get config "backendURL" "http://localhost:6060")
warn (obj/get config "demoWarning" true)]
(def default-language "en")
(def demo-warning warn)
(def url url)
(def url burl)
(def backend-url burl)
(def public-url purl)
(def default-theme "default")))

View file

@ -276,7 +276,6 @@
(ptk/reify ::handle-drawing-curve
ptk/WatchEvent
(watch [_ state stream]
(prn "handle-drawing-curve")
(let [{:keys [flags]} (:workspace-local state)
stoper (rx/filter stoper-event? stream)
mouse (rx/sample 10 ms/mouse-position)]

View file

@ -12,7 +12,9 @@
[cljs.spec.alpha :as s]
[uxbox.config :as cfg]
[uxbox.common.spec :as us]
[uxbox.util.worker :as uw]))
[uxbox.util.worker :as uw])
(:import
goog.Uri))
(defn on-error
[instance error]
@ -20,7 +22,10 @@
(defonce instance
(when (not= *target* "nodejs")
(uw/init "js/worker.js" on-error)))
(let [uri (Uri. cfg/public-url)]
(.setPath uri "js/worker.js")
(.setParameterValue uri "backendURL" cfg/backend-url)
(uw/init (.toString uri) on-error))))
(defn ask!
[message]

View file

@ -20,8 +20,20 @@
[uxbox.worker.selection]
[uxbox.worker.thumbnails]
[uxbox.worker.snaps]
[uxbox.util.object :as obj]
[uxbox.util.transit :as t]
[uxbox.util.worker :as w]))
[uxbox.util.worker :as w])
(:import goog.Uri))
;; --- Initialization
(this-as global
(let [location (obj/get global "location")
uri (Uri. (obj/get location "href"))
buri (.getParameterValue uri "backendURL")]
(swap! impl/config assoc :backend-url buri)))
;; --- Messages Handling
(s/def ::cmd keyword?)
(s/def ::payload

View file

@ -5,10 +5,16 @@
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
(ns uxbox.worker.impl
(:require [uxbox.util.transit :as t]))
(:require
[okulary.core :as l]
[uxbox.util.transit :as t]))
(enable-console-print!)
;; --- Config
(defonce config (l/atom {}))
;; --- Handler
(defmulti handler :cmd)

View file

@ -33,16 +33,18 @@
(defn- request-page
[id]
(p/create
(fn [resolve reject]
(->> (http/send! {:url "http://localhost:6060/api/w/query/page"
:query {:id id}
:method :get})
(rx/mapcat handle-response)
(rx/subs (fn [body]
(resolve (:data body)))
(fn [error]
(reject error)))))))
(let [url (get @impl/config :backend-url "http://localhost:6060")
url (str url "/api/w/query/page")]
(p/create
(fn [resolve reject]
(->> (http/send! {:url url
:query {:id id}
:method :get})
(rx/mapcat handle-response)
(rx/subs (fn [body]
(resolve (:data body)))
(fn [error]
(reject error))))))))
(defmethod impl/handler :thumbnails/generate
[{:keys [id] :as message}]

View file

@ -56,6 +56,7 @@ function build-frontend {
--mount source=${HOME}/.m2,type=bind,target=/home/uxbox/.m2 \
-w /home/uxbox/uxbox/frontend \
-e UXBOX_PUBLIC_URL=${UXBOX_PUBLIC_URL} \
-e UXBOX_BACKEND_URL=${UXBOX_BACKEND_URL} \
-e UXBOX_DEMO_WARNING=${UXBOX_DEMO_WARNING} \
-e UXBOX_DEPLOY_DATE=${UXBOX_DEPLOY_DATE} \
-e UXBOX_DEPLOY_COMMIT=${UXBOX_DEPLOY_COMMIT} \