Fork me on GitHub
#beginners
<
2016-06-21
>
adrien09:06:39

hello how do you update a clojure jar that runs a ring server? do I have to shut it down then restart it (or use something like /etc/inittab)?

urbanslug10:06:02

Hey, how come this is failing (contains? [\a \e \i \o \u] (first "aro”))

st10:06:36

@urbanslug:

(doc contains?)
-------------------------
clojure.core/contains?
([coll key])
  Returns true if key is present in the given collection, otherwise
  returns false.  Note that for numerically indexed collections like
  vectors and Java arrays, this tests if the numeric key is within the
  range of indexes. 'contains?' operates constant or logarithmic time;
  it will not perform a linear search for a value.  See also 'some’.`
In your example, a vector contains letters and test is made on indexes (map #(contains? [\a \e \i \o \u] %) (range 6)) shows that. Yes, it’s confusing. You can use instead the set of letters (contains #{\a \e \i \o \u} \e) returns true Frequently used: set is also a function returning given argument if it contains it: (#{\a \e \i \o \u} \e) returns \e itself.

madstap11:06:02

contains? works as you'd expect with sets (contains? #{\a \b \c} \a)

st11:06:17

You’re right @madstap, I edited my answer.

plexus12:06:23

@st the way to check if a collection (vector, seq) contains an element is to use some + a set: (some #{(first "aro")} [\a \e \i \o \u])

plexus12:06:19

@adrien you don't usually "update" a jar, you build a new one and switch to it by stopping the old server and starting the new one

plexus12:06:54

init/systemd/upstart can help with this

plexus12:06:22

e.g. I have this in /lib/systemd/system/lambdaisland.service

plexus12:06:46

that jar is a symlink to whatever the latest version is. When I deploy I update that symlink, then do systemctl restart lambdaisland to stop the old version and start the new one. The benefit of doing this with systemd is that it will automatically start at boot, and restart if the process dies

adrien13:06:56

thanks @plexus! That's exactly what I was looking for!

plexus13:06:38

happy to help! what this doesn't get you is zero-downtime deploy. It's not too hard to add, the short downtime while starting the new server just hasn't annoyed me enough yet

adrien13:06:30

🙂 same for me, it's a hobby project, but I'd like to have some users, and know how things work in production

adrien13:06:21

also, like this, it's easy to automate it with a Jenkins job, say, to have continuous deployment

adrien13:06:02

the article I found for Digital Ocean was using supervisor, which didn't feel very unix-y to me

adrien13:06:12

(hence my question)

adrien13:06:15

thanks again!

leo.ribeiro16:06:21

hey guys, how can I make my repl sees my new global that I created in the code with (def myvar) ?

jswart16:06:51

reload that namespace

jswart16:06:23

(require ‘[your.namespace :as n :reload]) then you can use it (n/myvar)

leo.ribeiro16:06:23

good! I was using (in-ns ‘my.namespace)

leo.ribeiro16:06:42

I will stop to do that and keep using user namespace requiring stuff

fingertoe17:06:50

Where do I specify namespaces I want my repl to always use on startup? i.e. (use ‘clojure.repl) so I have access to (doc ) and (source )

hrathod18:06:21

@fingertoe: I believe with leiningen, you can use a user.clj file to load up code

jjfine19:06:49

@fingertoe: in project.clj I've got a key :repl-options {:init-ns dev} and then in dev.clj:

(ns dev
   (:require
    [clojure.repl :refer [apropos dir doc find-doc pst source]] ...