The following program, when run from an überjar, exits at the end only when using the in-memory Datomic database; when connecting to the Datomic server, it hangs indefinitely rather than exiting the JVM:
(:use [datomic.api :only [db q] :as d])
;; WORKS: (def uri "datomic:mem://testdb")
(def uri "datomic:free://localhost:4334/testdb2")
(defn -main 
(when (d/create-database uri)
lein uberjar && java -cp target/myns-0.1.0-SNAPSHOT-standalone.jar myns.example
and hangs. It only hangs if the DB doesn't exist when the program starts.
Anyone know why, or how to fix? This is with both
UPDATE -- the above program does actually terminate, but it takes a very long time (> 1 minute). I'd like to know why.
shutdown-agents takes up to one minute to complete (assuming no agents are running an action).
This is due to the way
java.util.concurrent cached thread pools work.
Usage: (shutdown shutdown-clojure)
Shut down all peer resources. This method should be called as part of clean shutdown of a JVM process. Will release all Connections, and, if shutdown-clojure is true, will release Clojure resources. Programs written in Clojure can set shutdown-clojure to false if they manage Clojure resources (e.g. agents) outside of Datomic; programs written in other JVM languages should typically set shutdown-clojure to true.
Added in Datomic Clojure version 0.8.3861
(ns myns.example (:require [datomic.api :as d]) (:gen-class)) (def uri "datomic:free://localhost:4334/testdb2") (defn -main  (d/create-database uri) (let [conn (d/connect uri)] (try ;; do something (finally (d/shutdown true)))