Fork me on GitHub
#hyperfiddle
<
2024-01-29
>
chromalchemy02:01:53

I’ve successfully deployed to http://fly.io before. I thought I remembered a comment to maybe avoid it if you don’t need the distribution model? I have a Digital Ocean droplet ready to go with a domain.. or I could use something else. Does anyone have any guidance on the simplest path? Is it easy enough to use an Uberjar directly? (the droplet has been previously provisioned with Biff setup bash script). So far, the docs are quite terse, and googling around uberjar stuff is a bit mystifying… . Would it be easier to use docker and Digital Ocean App Platform? Or just use Fly as before?

Dustin Getz12:01:37

yes use uberjar

Dustin Getz12:01:10

ssh to droplet, run

java -cp target/app.jar clojure.main -m prod

chromalchemy14:01:40

Thanks, will give it a go.

chromalchemy23:01:31

@U09K620SG I got the XTDB Fiddle deployed to a Digital Ocean VPS droplet! 🙌clojure-spin Took me all day grinding. First I pulled Electric fiddle into my project on a new branch. I got the fiddle running locally, learning to respect adding the prescribed XTDB_ENABLE_BYTEUTILS_SHA1=true Then focusing on deployment: I Complied the uberjar from the fiddle with the above command. Ubuntu on my droplet was complaining about being old and unsupported, but wouldn’t update. So I wiped the droplet and started from scratch, and had to fiddle with ssh keys. I wasn’t sure how much the system need to run a jar. So I installed just java and tried to run the jar at root. Nothing. So I walked though the Biff https://github.com/jacobobryant/biff/blob/dev/example/server-setup.sh script, running the parts that looked meaningful to a clean build. I left out nginx thinking that would be handled by the jar.. Still nothing. So I set up nginx and a certbot, then it would load, but not showing any content. I needed to add the env var in the right spot on the jar call XTDB_ENABLE_BYTEUTILS_SHA1=true java -cp app.jar clojure.main -m prod Up and working!! Reactive multiplayer feels magical! I did get one crash with client_loop: send disconnect: Broken pipe . My internet connection went out about the same time. Will set up systemd to auto-reboot..? In retrospect I was in a bit over my head, and probably should have just gone with docker and a service to save time. But i did get some hard won learnings and confidence flexing on the devops side (a weak spot for me). I’m glad to have the electric fiddle repo as a launchpad. I was tempted to go with the starter repo, but I figured this was more likely to be up to date and provide more working example code. Thanks for the considerations on that.

Dustin Getz23:01:50

are you saying our xtdb fiddle is missing a readme step or something? sorry you had to debug that, it doesn’t seem like electric issues, these all look like xtdb issues

Dustin Getz23:01:14

it has the env var

Dustin Getz23:01:58

fwiw the starter app is up to date as of friday or so, but we don’t intend to maintain database specific starters outside of the fiddle repo

Dustin Getz23:01:00

oh i see, you didn’t know how to install clojure cli

chromalchemy00:01:15

I think the fiddle, and the documentation is fine. The environmental var was in the documentation. That was all about me noodling through the deployment process outside of electrics concerns.

chromalchemy00:01:03

I have the closure CLI command installed locally. I’m not sure if I installed it remotely. I was under the impression and I didn’t need that to run the Uber jar.

chromalchemy00:01:19

Just a little journal about me learning to deploy an Uber jar.

chromalchemy00:01:39

There is a little variation on where the environment variable goes in the clojure CLI, versus the Java commands. Thankfully, I got a error read out in the consul, when it wasn’t included properly, when I tried to run the jar in production. And that alerted me to get it right

Dustin Getz00:01:22

you do not need clj for uberjar, sorry

Aviv09:01:46

Hey everyone, Does datomic-browser work with datomic-cloud? Thanks 🙏

Geoffrey Gaillard08:01:38

The datomic browser uses the datomic peer api. We haven’t tried to adapt it to datomic cloud.

🙏 1
Aviv08:01:04

Oh ok, thanks! are there any plans to support it?

Geoffrey Gaillard09:01:08

I’m not sure, I’ll ask

👌 1
Geoffrey Gaillard14:01:15

We are not planning to adapt datomic-browser to datomic cloud. But if you want to do so, there is datomic-cloud compatible code in our https://github.com/hyperfiddle/electric/tree/master/src/contrib.

Aviv15:01:17

thanks! i’ll take a look

Vincent22:01:04

So... using the new fiddles approach...

Vincent22:01:32

I have "app navigation" where I have it look at the first subfolder in the url ... right? localhost:8080/browse for example

Vincent22:01:09

However, the hyperfiddle examples application overrides this on page refresh....

Vincent22:01:21

wants things to conform to for example (ShompMain)

Vincent22:01:19

question... how can i stop the examples app from reading the URL location and changing it? I will look in the code, this is not helpful for developing routing/navigation #2¢

Vincent22:01:21

So yeah 😅 can someone help me find out how I can make the fiddles manager not override navigations?

Vincent22:01:12

I am stoked at the ability to now mint prod versions easily, I think that's cool, but I'm really not clear on how I can remove some of the scaffolding around the examples browser so I can get back to messing with the navigation myself. Since in the application people ought be able to click nav buttons and have it reflected in the location bar / url.

Vincent22:01:34

Ah ok I found where this is happening:

(ns electric-fiddle.main
  (:require
   [hyperfiddle :as hf]
   [hyperfiddle.electric :as e]
   [hyperfiddle.electric-dom2 :as dom]
   [hyperfiddle.router :as r]
   [electric-fiddle.index :refer [Index]]
   ))

(e/defn NotFoundPage [& args] (e/client (dom/h1 (dom/text "Page not found: " (pr-str r/route)))))

(e/defn Main [ring-req]
  (e/server
    (binding [e/http-request ring-req]
      (e/client
        (binding [dom/node js/document.body]
          (r/router (r/HTML5-History.)
            (dom/pre (dom/text (pr-str r/route)))
            (let [route       (or (ffirst r/route) `(Index)) ; route looks like {(f args) nil} or nil
                  [f & args]  route]
              (set! (.-title js/document) (str (some-> f name (str " – ")) "Electric Fiddle"))
              (case f
                `Index (Index.)
                (r/focus [route]
                  (e/apply (get hf/pages f NotFoundPage) args))))))))))

Vincent22:01:54

And I'm wondering what I ought to do to.... take this over elegantly 😅

Vincent22:01:42

Also, the "not found page" is optimistic and never evaluated, I think. Because it has to conform to the very specific formula for what a page is, otherwise it's not ISeqable and the "page not found" page is actually a name and the word nil so... just something to keep in mind. Wrenching out this plumbing is taking some effort )

Vincent22:01:02

NVM noticing a new electric-starter-app

Dustin Getz23:01:54

yes use starter app

👍 1
Geoffrey Gaillard08:01:50

Are you saying there is a conflict between the default client side routing and your custom server side routing?

Vincent12:01:00

Everything I said is irrelevant ) Was gutting the demos app ... and there is no need for that now