This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-23
Channels
- # admin-announcements (38)
- # announcements (1)
- # aws (1)
- # beginners (195)
- # boot (1)
- # business (3)
- # cider (100)
- # cljsrn (37)
- # clojure (99)
- # clojure-russia (69)
- # clojure-switzerland (1)
- # clojurescript (120)
- # datavis (26)
- # datomic (23)
- # devcards (4)
- # editors (38)
- # hoplon (18)
- # ldnclj (27)
- # lein-figwheel (28)
- # off-topic (50)
- # om (329)
- # onyx (255)
- # portland-or (1)
- # re-frame (8)
- # reagent (18)
- # spacemacs (5)
- # testing (1)
How to people come up with good values for -Xmx/-Xms on servers? I'm running a JVM on AWS's m3.medium with 3764 MB total RAM.
With -Xmx3400m -Xms3400m
, I see eventually see mmap errors: Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00007fab0a3fd000, 12288, 0) failed; error='Cannot allocate memory' (errno=12)
(no swap on these machines)
@pesterhazy: give the OS ~ 1GB. Then it depends on your app (e.g. does it rely on the page cache etc)
@tcrayford: so -Xmx(TOTAL_MEM - 1G)
? interesting, I wouldn't have assumed you need that much leeway
@pesterhazy: you can probably get away with less leeway if and only if you promise to never run anything else on the machine
e.g. you never login to it and do anything memory intensive, you don't run nginx or anything else like that etc etc
yeah, these machines are pretty much jvm-only
but you're right, I do ssh in sometimes and do stuff, so it's better to err on the safe side
e.g. if you pipe a large log file into vim on the machine rather than scping it off, you don't want linux to OOM kill your JVM app whilst doing so
I’m having some issues, it won’t connect to the database, but it works locally. I added some log statements, and it seems like the start
method in the db component isn’t even called.
this is how my db compnent looks:
(defrecord Database [mongo-uri]
component/Lifecycle
(start [this]
(log/info "Trying to connect to " mongo-uri)
(let [{:keys [conn db]} (mg/connect-via-uri mongo-uri)]
(log/info "Connected to mongo.")
(assoc this :db db :conn conn)))
(stop [this]
(when-let [conn (:conn this)]
(mg/disconnect conn))
(log/info "Disconnected from mongo.")
(dissoc this :db :conn)))
(defn start-database [mongo-uri]
(log/info "Will attempt to connect to " mongo-uri)
(log/info "Connected: " (mg/connect-via-uri mongo-uri))
(map->Database {:mongo-uri mongo-uri}))
@roberto: how are you starting your system in Heroku? Does it work locally if you build an uberjar and run it with java -jar uberjarname.jar
?
yeah, it starts locally. Okay, now it is connecting to the db, but I’m getting a NPE, which I don’t get locally.
(defrecord HttpServer [db-component api-routes html-routes]
component/Lifecycle
(start [this]
(let [port (env :server-port)
auth-handlers (-> (routes (:handlers api-routes) (:handlers html-routes))
(friend/authenticate {:allow-annon? true
:workflows [(auth-config/workflow auth-config/client-config (partial credential-fn (:db db-component)))]}))
server (run-server (wrap-defaults auth-handlers
(assoc-in site-defaults [:security :anti-forgery] false))
{:port port :join? false})]
(log/info (str "Started server on port " port))
(assoc this :server server)))
(stop [this]
(stop-server (:server this))
(assoc this :server nil)))
(defn create-system
[{mongo-uri :mongo-uri :as config}]
(component/system-map
:html-routes (start-html-routes)
:db-component (db/start-database mongo-uri)
:api-routes (component/using
(map->ApiRoutes {})
[:db-component])
:app (component/using
(map->HttpServer {})
[:db-component :api-routes :html-routes])))
(defn -main
[& args]
(component/start (create-system {:mongo-uri (env :mongo-uri)})))
it says the NPE is where I’m starting the server:
server (run-server (wrap-defaults auth-handlers
(assoc-in site-defaults [:security :anti-forgery] false))
{:port port :join? false})
hi all--very excited to be beginning my journey into clojure
welcome to clojure @davebryand . I hope you enjoy your journey.
hi everyone. Anyone know about how to pass a Java 8 method reference eg FileSensor::create in Clojure?
Can't find anything useful.
@fergalbyrne: Are you passing it from Java to Clojure or vice versa?
From Clojure to Java.
@fergalbyrne: I haven't tried this, but my first thought is to try and reify java.util.function.UnaryOperator
something along the lines of (reify java.util.function.UnaryOperator (apply [_] (FileSensor/create)))
Cool, I'll try that. Thanks
OK, that was on the right track, ta very much. This at least compiles: (def fs-creator (reify org.numenta.nupic.network.sensor.SensorFactory (create [_ params] (FileSensor/create params))))
(the Java method accepts a SensorFactory or a reference to a method, so this is a workaround).
I like using environ for that sort of thing. A nice abstraction over system properties.
~
as home dir is a Unix convention; Java-based tools generally don't support it.
Are there any up to date tutorials for luminus?
@bronsa: I think I figured out my AOT bug from the other day: http://stackoverflow.com/questions/19594360/preserving-timestamps-on-clojure-clj-files-when-building-shaded-jar-via-maven-s It only happens on the shaded jar, not when I run with maven directly.
Any good tutorials for web development with clojure
@hectorqlucero: The docs page is pretty much a full tutorial http://www.luminusweb.net/docs
@hectorqlucero: https://pragprog.com/book/dswdcloj/web-development-with-clojure
Thanks
i feel like there’s a core function for what’s going on in the anon fn here: (map #(or (:some-kw %) “default"))
is there?
of course, yes
now that i didn’t know!
i think i prefer the or
, tbh
beware there is a subtle difference:
user=> (get {:key nil} :key "default")
nil
user=> (or (:key {:key nil}) "default")
“default”
your first example is wrong, jr
you’re trying to read the key “default” from the map
mrb welcome!
jr: truth
then or
is definitely my friend here
can anyone help me understand why this doesn’t work?
eng-dacom.repl=> (def a "11111111-1111-1111-1111-111111111111")
#'eng-dacom.repl/a
eng-dacom.repl=> #uuid a
AssertionError Assert failed: (string? form) clojure.uuid/default-uuid-reader (uuid.clj:11)
#uuid
is a reader macro. it requires a string literal and you are giving it a symbol
I see this here now: https://crossclj.info/ns/org.clojure/clojure/1.8.0-RC2/clojure.uuid.html#_default-uuid-reader
What I’d like to do is to pass a string into my function and then tag that with #uuid
to forward on to datomic. Something like this. Do you know how to accomplish this?
(def get-person [uuid]
(ffirst (q get-person-query
(db @conn)
[:entity/uuid #uuid uuid])))
the reader macro is syntactic sugar for literal values, just like #inst
for dates. you string uses java.util.Date
to create them at runtime
good call—I’m new to all this and I guess at the end of the day the whole point of the tagging is to just get the reader to get me a UUID obj
perfect—thanks @samflores
What is the most convenient way of working with clojure datastructures from another JVM languages nowadays?
happy to report clojure 1.8's working fine on our codebase, embedded in a spring/dropwizard app with elasticsearch/elastisch, core.match/analyzer/reader and clj-antlr, notably.
can anyone weigh in for a noob on whether or not the way that the conn is managed as an atom in the dacom
skeleton app is still considered best practice? https://github.com/bellkev/dacom/blob/master/src/dacom/server.clj#L14
Question about a former behavior of Clojure: back in the day (pre-1.4 I think), it used to wrap exceptions in RuntimeException
in some cases. I modified clojure.java.jdbc to unwind RTEs to expose the underlying exception (so you could easily catch SQLException
) but now I can’t figure out exactly how to repro that wrapping.
I’d like to remove the whole throw-non-rte
thing from the code, so it doesn’t unwrap ex-info
and other things, but I need a test that verifies the wrapping behavior to see which Clojure versions will no longer work.
It seems related to http://dev.clojure.org/jira/browse/CLJ-855 but I can’t figure out a simple test case that runs into that...
NM, I ended up pulling the FileNotFoundException
example from the mailing list thread linked in CLJ-855 and that verifies the behavior was only there for Clojure 1.3.0 so I think I’m just going to drop support for that in the next version of clojure.java.jdbc (which will therefore be 0.5.0).