Skip to content

Latest commit

 

History

History
156 lines (103 loc) · 6.76 KB

2019-6.md

File metadata and controls

156 lines (103 loc) · 6.76 KB

June

June 8

I would like to gradually replace all of the Google apps that I use to manage my personal data. While I'm at it, I'd like to combine all of the productivity apps that I use into one single app, a kind of super-notes app I'm calling cards at the moment.

Step #1, learn more about Sandstorm. At the moment I use Sandstorm to host Tiny Tiny RSS and a few other 3rd party self-host experiments. I'd like to use it for my own apps as well.

Time to read the docs!

Some intital questions:

  1. how do sandboxed apps (grains) become active?
  • it seems like they're inactive until opened in the UI but then how does my tt-rss app talk to the server for updates?
  1. how do I wrap a clojure app?

To setup an app, Sandstorm uses several shell scripts that run a different points. To wrap a clojure app I'll need to add things to those scripts.

setup.sh

This seems to be where I put my platform setup code. It runs once when I run vagrant-spk vm up. My app is an [Edge] Clojure app which uses clj. The clojure docs say to install bash, curl, rlwrap, and Java then run:

curl -O https://download.clojure.org/install/linux-install-1.10.1.447.sh
chmod +x linux-install-1.10.1.447.sh
sudo ./linux-install-1.10.1.447.sh

After editing setup.sh I need to run vagrant-spk vm provision. To confirm it works I can also run vagrant-spk vm destroy then vagrant-spk vm up.

build.sh

This looks like where I put my app setup code. It runs each time I run vagrant-spk dev. Presumably this is where I'll start the app using a dev profile. How do I access the REPL from within Sandstorm?

Or is this where I build an uberjar?

launcher.sh

This looks like where I put code that runs each time a user opens the app. I signal that the app is ready by listening on port 8000 for HTTP requests.

When running my app /var is the only directory that persists between loads.

now what?

My biggest question at this point is: should I just build an uberjar outside of Sandstorm as part of my clj workflow?

Lets try that first. First I build an uberjar in the project root, then add these:

;; setup.sh
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y default-jre
exit 0

;; launcher.sh
cd /opt/app
java -jar bontu.jar
exit 0

Doesn't work :( Trying to launch a new grain gives "The connection to the server was reset while the page was loading.".

Testing the bontu.jar outside of Sandstorm and it doesn't work anyway, there's the problem. Something is wrong with the uberjar building process. I think it was a mistake trying to get Sandstorm working with a brand new Edge app that I don't fully understand yet.

trying again

I'm going to try starting a clojure(script) app from scratch and getting it working with Sandstorm. Lets start by getting a basic yada app running.

Well. I spent most of the day trying to get any of the uberjar builders to work at all. Here's my deps.edn:

{:paths ["src"]
 :deps
 {org.clojure/clojure {:mvn/version "1.9.0"}
  yada {:mvn/version "1.2.15"}
  #_#_integrant {:mvn/version "0.70"}}

 :aliases
 {:depstar
  {:extra-deps
   {seancorfield/depstar {:mvn/version "0.2.1"}}}

  #_#_
  :uberjar
  {:extra-deps {uberdeps {:mvn/version "0.1.4"}}
   :main-opts ["-m" "uberdeps.uberjar"]}

  #_#_
  :pack
  {:extra-deps {pack/pack.alpha {:git/url "https://github.com/juxt/pack.alpha.git"
                                 :sha "a41ae7b7f2381861eea0c937748c1377d463b955"}}}

  #_#_
  :uberjar
  {:extra-deps
   {luchiniatwork/cambada {:mvn/version "1.0.0"}}
   :main-opts ["-m" "cambada.uberjar"
               "-m" "cards.server"]}

  #_#_
  :uberjar
  {:extra-deps
   {cambada/cambada {:mvn/version "1.0.4"}}
   :main-opts ["-m" "cambada.uberjar"
               "-m" "cards.server"]}}}

All of them failed for some reason or another. Need to have another go when I'm in a better headspace!

June 9

Ok. Became a little stymied by build tools yesterday. Brought it on myself by trying to rush things. I don't really understand what these tools are doing under the hood and that made things difficult when they didn't work straight away.

So today I'm going to make things worse by having a quiiick go at building a GraalVM native image!

For starters, I somehow managed to forget that AOT means that my namespaces would be loaded during compilation, and my server namespace was using a demo example that just 'def'ed the server. Whoops!

Ok so Graal won't compile and of the http servers that I tried (yada, aleph, http-kit) but it was probably a bad idea anyway. New plan: run the app using clj on the server. I used the original setup.sh stuff from yesterday and it seems to work fine.. except running the grain gives /usr/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory. I've googled but I'm not sure how to fix this.

I tried switching to open-jdk and broke my vagrant setup somehow? Yikes this stuff is frustrating. Should I just switch to running clojurescript on nodejs?

June 10

When I create a new vagrant VM using vagrant-spk up, it won't mount shared folders as the kernel module vboxsf isn't being loaded correctly (inside the VM).

==> default: Mounting shared folders...
    default: /opt/app => /home/tom/git/cards
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=1000,gid=1000 opt_app /opt/app

The error output from the command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

Command failed with a non-zero exit status (1).

I've tried reinstalling VirtualBox Guest Additions inside the VM and running modprobe vboxsf but I can't get it going.

I think the problem is that I uninstalled some Vagrant plugins yesterday. I reinstalled vagrant afterwards so perhaps I was using a plugin that I no longer have as I'm back to a default install? Upgrading plugins doesn't work.

Trying vagrant box update --box debian/contrib-stretch64 and updating .sandsorm/Vagrantfile to the new version has the VM working again.

Now.. what's the easiest way I can serve a clojurescript UI from inside Sandstorm?

Serving some built clojurescript via Sandsorm's static stack works great!

Could I make services that run on Sandstorm with planck?