Installation
Crux nodes can be embedded within your JVM application, or they can be started standalone through a pre-built Crux JAR, via Docker, or using Clojure CLI tooling.
This guide will show you how to set up an in-memory node using the crux-core
module.
You can then proceed to add further modules (eg for persistence) as required - see the documentation of the individual modules for more information.
Within your JVM application
First, add the crux-core
module as a project dependency.
We can then start up an in-memory Crux node with:
(require '[crux.api :as crux])
(crux/start-node {})
import crux.api.Crux;
import crux.api.ICruxAPI;
public static void main(String[] args) {
try(ICruxAPI cruxNode = Crux.startNode()) {
// ...
}
catch (IOException e) {
// ...
}
}
import crux.api.Crux
fun main() {
Crux.startNode().use {
// ...
}
}
Using a pre-built Crux JAR
You can start a standalone Crux node, accessible through HTTP, using a pre-built Crux JAR.
Crux pre-built JARs can be found on the relevant GitHub releases page - we’ll use crux-in-memory.jar
.
Start it in the usual way, with java -jar crux-in-memory.jar
.
This will open an HTTP port with a console UI on port 3000 - open http://localhost:3000 in your favourite browser.
You can also build custom Crux JARs with your choice of modules - see the Crux build blog for more details.
Via Docker
You can also start a standalone Crux node using Docker, using:
docker run -p 3000:3000 juxt/crux-in-memory:1.18.0
Again, this opens up an HTTP server at http://localhost:3000.
Likewise, you can build custom Crux Docker images - see the Crux build blog for more details.
Clojure CLI tooling
Similarly, to start Crux using Clojure’s CLI tooling:
{:deps {org.clojure/clojure {:mvn/version "1.10.3"}
pro.juxt.crux/crux-core {:mvn/version "1.18.0"}
pro.juxt.crux/crux-http-server {:mvn/version "1.18.0"}}}
Then, start the node with clojure -m crux.main
.
You can get a listing of CLI flags using clojure -m crux.main -h
.