Fork me on GitHub
#off-topic
<
2019-11-07
>
Ahmed Hassan04:11:20

How do you deploy your Clojure applications? Especially for single developer?

seancorfield05:11:50

@ahmed1hsn Deploy to production?

seancorfield05:11:59

It depends on your needs. I think a lot of people build "uberjars" sort of by default and deploy those, and then run them via java -jar ...

👍 4
seancorfield05:11:06

But you can deploy source and run them via your chosen "build" tool. We used to do this with lein run and then with boot run. Some things we still run via clojure -m ... nowadays.

👍 4
seancorfield05:11:44

Mostly we build uberjar packages but without AOT and without a manifest, so we run them in production with java -cp ... clojure.main -m ...

👍 4
seancorfield05:11:35

Some platforms prefer a WAR file but I think that's used by a minority of Clojure developers these days.

👍 4
seancorfield05:11:03

So... a lot depends on where you are deploying your apps and what tooling is the default on those platforms.

👍 4
seancorfield05:11:29

Does that help @ahmed1hsn?

🙂 4
Ahmed Hassan05:11:13

Thanks @seancorfield. There's http://dokku.viewdocs.io/dokku/ too. But it can run on only single server.

Ahmed Hassan05:11:05

What is difference between deploying app with JAR as you mentioned and with something like Dokku?

seancorfield06:11:27

Never heard of Dokku and that link doesn't work for me right now.

seancorfield06:11:46

I've no idea what the braveclojure link is recommending since it seems to just refer to a book that I would need to pay for?

seancorfield06:11:03

OK, so braveclojure is suggesting Digital Ocean as a host.

seancorfield06:11:33

Looks like the shell scripts it talks about create an uberjar and deploy it to the VM at Digital Ocean so, yeah, that's one of the methods I talked about above.

💯 4
henrik07:11:41

We deploy to Datomic Cloud.

Ahmed Hassan07:11:38

I'm not able to understand how these pieces come together.

henrik07:11:18

Datomic Cloud is a “managed” way to deploy as opposed to spinning up your own servers and so on, though it relies on setting up a Datomic Cloud deployment on AWS. If you’re just trying things out, this isn’t the way to go: it’s quite complicated. More here: https://docs.datomic.com/cloud/index.html

👍 4
vemv10:11:41

I'd look into AWS ElasticBeanstalk - it's heroku-like but with a cleaner path for scalability there are some clojure-centric facilities around it What I like about EB or Heroku is that it gives you a basic flavor of resiliency (bluegreen deployments, etc) w/o going full-blown devops

Ahmed Hassan11:11:22

@U45T93RA6 Dokku works similar to Heroku but It is only for single server machine setup (on DO or Linode). It's much cheaper than EBS or Heroku. What I'm curious about is deployments on multi node (machine) setup.

👍 4
henrik13:11:43

I set up Dokku years ago for something (on DigitalOcean nonetheless) and remember that it was quite nice to work with. More or less Heroku-like API. I never did deployments to multiple nodes with it though. For deployments to multiple nodes, most of the action happens outside of the server itself. I.e., maybe there’s a load balancer that distributes traffic to the nodes, and maybe there’s an external DB that all nodes talk to, but normally you don’t need the nodes themselves to be aware of one another. I.e., most of these concerns have very little to do with Clojure (or whatever is running inside the nodes), and much more to do with your infrastructure. Whatever Dokku says on deployments to multiple nodes is what you’d go with, that is.

💯 4
murtaza5206:11:12

Hi needed some advice on buying a new laptop, my main concern is durability. I would not like to throw away my machine after 3-5 years, and even if the specs get outdated after some years of usage, the machine still should be functional. What machine would you suggest ? Portability, sleekness is least of my priority. Durability, solid build, functionality and linux compatibility are top priorities. I am currently using a mac book pro and have used thinkpad before that. Not happy that they are not sustainable, after years of usage they are just bricks.

seancorfield06:11:03

Not sure what you're looking for if you think a MBP is a "brick" after ... how many years? @murtaza52

seancorfield06:11:20

Over the nearly 30 years that I've owned dozens of laptops, I'd rank Apple and Dell as near the top of reliability and durability. I can't speak to IBM/Lenovo but I know folks who've had good luck with them.

seancorfield06:11:10

My experiences with most other brands has been poor (HP, Toshiba, Sony, and a few others that I don't recall right now).

murtaza5206:11:11

Ok maybe I was dramatic, I have MBP which I have been using for 4 years. The battery does not charge at all and the machine has to be kept plugged in (which I think can be fixed), however what troubles me is the heating of the machine, the occasional crashes, the frequent freezing of applications. MBP was pretty stable before, but in last few months it seems it has aged. Thinkpad also server me well, but today everything is blown up - the battery, the power unit, the motherboard - I was using it in a place which ahd frequent power outages, and the constant power on/off did it in.

seancorfield06:11:09

Ah, so abuse of the laptop... yeah, that's hard to defend against. As for the MBP battery, that's a common issue after ~4 years but you should be able to get a replacement battery and be good for another few years?

seancorfield06:11:46

TBH, I think most laptop manufacturers expect you to simply replace your machine every "few" years. Batteries aside, well-made laptops last for many years, but batteries are definitely the weak spot. Most of my laptops have reached a point where their batteries will not hold a charge. I'm somewhat surprised that my Dell XPS12 (that I'm typing on right now) still seems to hold 3-4 hours of charge after all the abuse it has had. I can't remember how many years old it is.

seancorfield06:11:06

Looks like it's 6-7 years old.

seancorfield06:11:21

Based on the processor model identifier, I think it's a 2013, not a 2012.

seancorfield06:11:37

Like I say, I've been happy with the reliability of Dell laptops.

murtaza5206:11:35

Battery replacement is fine, however I just feel its a wastage if the laptop becomes unusable. At the least I should be able to give it away to someone else in a working condition. My issue with MBP is the heating issues, freezes and crashes, which makes me think very soon this will become unusable.

murtaza5206:11:03

@seancorfield thanks let me check out the dell ones

seancorfield06:11:15

Unfortunately we live in a world of built-in obsolescence and disposable technology 😞

mpenet06:11:21

Dell has also incredible support. The few times I had issues I got replacements, on site, in 24h

mpenet06:11:23

Ex: dropped laptop on the floor, screen/case busted, replaced both no questions asked

seancorfield06:11:03

I literally have a stack of old laptops in my office that are no longer usable for a wide variety of reasons. My 2012 27" iMac is pretty much EOL at this point and lots of software complains that I'm still running macOS 10.12 and that's unsupported -- and quite a few things refuse to install now. My iPhone 5S is similarly stuck on iOS 12 and lots of things are no longer updating.

seancorfield06:11:14

Apple is more aggressive about EOL'ing stuff than Microsoft seems to be, which is why I'm switching to Windows/Android for my next set of devices. I'm already running Windows 10 on my Mac and mostly Microsoft apps on my iPhone anyway...

seancorfield06:11:30

(bedtime here)

murtaza5207:11:10

yup and disposable technology is what concerns me, I think the new awareness of the wastage caused by technology and its effect on environment is also playing on my mind. My next choice of laptop / phone, I want something which does not have to be disposed off. At the end of its usage, I should be able to hand it over to someone who can put it to a better use. In terms of OS, I have switched to manjaro linux. In my current MBP also I have installed manjaro. It did take some time to get everything configured, but I am happy with the choice.

4
andy.fingerhut07:11:02

"at the end of its usage, ... to someone who can put it to better use" -- do you mean as something besides a computer? Given the still-rapid advance of technology, 15 year old computers sell for peanuts on eBay, if they sell at all.

murtaza5207:11:01

nope I meant giving it away for charity if I cant use it, there are kids from economically disadvantaged backgrounds who would be happy to have a machine for learning purposes.

murtaza5207:11:31

and I am based in Africa, even old machines in working condition are valued, so its a shame if our expensive machines cant be reused.

Mno08:11:49

Weird I still actively use a MBP from mid 2010 and it works fine for me.. (after I had the logic switched out because of a manufacturing fault)

mloughlin09:11:29

I can't speak to the state of their recent models, but I've had a Thinkpad X220 for years and it's still chugging along. I had to replace its battery once but it's almost indestructible

mloughlin09:11:40

X220 is from ~2012

dominicm11:11:58

Is there anything nice for parameter globbing something like find -type f? Preferably something where I don't have to think about files with spaces in, stuff like that.

dharrigan11:11:40

Have you tried using fd rather than find?

dominicm11:11:30

fd is good, but doesn't solve this case:

/tmp loading                                                   0.05s 11:21:04
❯ cd test            

/tmp/test loading                                              0.04s 11:21:05
❯ mkdir "foo bar"

/tmp/test loading                                              0.04s 11:21:13
❯ ls `fd`        
ls: cannot access 'foo': No such file or directory
ls: cannot access 'bar': No such file or directory

dharrigan11:11:15

with find you can do -print0 to strip out spaces

dominicm11:11:55

I think that keeps spaces, but separates by nul rather than newline

dharrigan11:11:19

ah, you're right! 🙂

dominicm11:11:53

That's an important trick for separation. But I want some convenient way to tell zsh how to handle -print0 in command output.

Alex Young11:11:41

The -0 arg to xargs is designed for that

dharrigan11:11:59

Yes, normally when I do -print0, it's in combination with xargs and -0, i.e., find . -print0 | xargs -0 rm -rf 🙂

dominicm11:11:59

❯ fd -0 | xargs -0 ls
'foo bar'
Just doesn't have the same convenience to it I guess 🙂 It's not parameter expansion.

dominicm11:11:07

(this is why shells suck I guess right?)

futuro11:11:43

If you could get find or fd to quote each result, that would do it.

futuro12:11:44

The issue from your example is that the results from fd are passed to ls as-is, but one of the results has the IFS in it.

futuro12:11:55

IFS=^v0 ls $(fd -0) might work

futuro12:11:58

Or perhaps ls $(OFS=\" fd)

futuro12:11:40

Some kind of song and dance with IFS and OFS values

futuro12:11:05

Depending on your shell, however, globbing may do the trick. ls *(#q.) should list all the files in the current directory in zsh

dominicm12:11:25

Nesting was important, and filtering only to files.

futuro18:11:17

**/*(#q.) should traverse down directories and return files

futuro18:11:43

Though I may have misunderstood your comment.

dominicm19:11:00

I shall have to examine that closer then!

walterl12:11:00

@dominicm A pattern I often use for iterating over file names with spaces in them is find ... | while read fn; do echo $fn; end

dominicm12:11:36

Fish appears to have a neat solution to this

borkdude12:11:48

@dominicm :

$ touch "dude where's my file"
$ find .
.
./dude where's my file
$ find . | bb -i -O '*in*'
"."
"./dude where's my file"

dominicm12:11:26

Yeah, I guess I'm looking for something concise and arcane to use for typing, not scripting

borkdude12:11:30

or even:

$ find . | bb -i '*in*'
("." "./dude where's my file")

dominicm12:11:39

@borkdude ah, now just to rewrite ls :D

borkdude12:11:00

$ ls | bb -i '*in*'
("dude where's my file")

dominicm13:11:43

I'm sure I can break that 🙂

dominicm13:11:01

$ touch "foo
bar"
❯ fd | bb -i '*in*'
("foo" "bar" "foo bar")
Not quite right

borkdude13:11:16

I'm sure I can fix that 😛

$ touch "foo
bar"
$ bb '(map #(.getPath %) (.listFiles (io/file ".")))'
("./dude where's my file" "./foo\nbar")

borkdude13:11:26

$ export BABASHKA_PRELOADS='(defn ls [] (map #(.getPath %) (.listFiles (io/file "."))))'
$ bb '(ls)'
("./dude where's my file" "./foo\nbar")

dangercoder15:11:22

any recommended edn->yaml converter?

borkdude16:11:21

@jarvinenemil sounds like a cool new feature for jet: https://github.com/borkdude/jet

borkdude16:11:35

(but not of any help right now)

dangercoder16:11:03

i guess one could add an already existing yaml reader to formats.clj

borkdude16:11:10

Yes. I created an issue for it. Open to PR

👍 4
flowthing19:11:09

Spent the evening banging my head against the wall trying to get GitHub Actions dependency caching (which rolled out a couple of days ago) working for a tools.deps project. I think I finally got it: https://github.com/eerohele/sigel/blob/4d6fc6d11520f37a06cac69b811bac4ecaa88953/.github/workflows/clojure.yml Might save you some time if you're considering giving GitHub Actions a go.

Alex Miller (Clojure team)20:11:26

what's the purpose of ${{ hashFiles('**/deps.edn') }} ?

dominicm20:11:44

I'm guessing the m2 cache is discarded when that changes. Then the new value is stored there. Might not do the discard part.

Alex Miller (Clojure team)20:11:56

but the m2 cache is still good, even when deps.edn changes

flowthing20:11:51

Right, that's a good point. I didn't think about that too hard yet — just wanted to get caching to work as a first step.

Alex Miller (Clojure team)20:11:19

that's the beauty of append-only immutable data :)

Alex Miller (Clojure team)20:11:29

heck, it's mostly not even os-dependent so ${{ runner.os }} isn't even that critical (os-specific maven classifier selection will vary, but I still think it'd be safe to keep the other os classifier versions)

Alex Miller (Clojure team)20:11:09

the other thing to consider might be your ./.cpcache dir

Alex Miller (Clojure team)20:11:25

certainly less critical than m2 and gitlibs

dominicm20:11:33

Caches are usually assumed to be immutable in CI, once named, never changed.

Alex Miller (Clojure team)20:11:14

so you can't add more to it?

Alex Miller (Clojure team)20:11:39

sorry, this is the first time I'm looking at the gh action cache stuff

dominicm20:11:50

In the past I've keyed it off build number, no idea if Github offer that. I only used that in conjunction with a CI that offers prefix sharing on cache keys (usually separated by a -)

dominicm20:11:10

No, these are good points to raise. I'm not intimately familiar with Github's caching here, I'm speculating.

flowthing20:11:00

Yeah, I don't think it gets discarded, but I'm not 100% sure.

flowthing20:11:21

If not, I'm trying to think of a scenario where the hashFiles bit is necessary... can't come up with any off the top of my head, so yeah, it's probably not needed.

flowthing20:11:51

I thought about caching .cpcache, but the performance gains there are probably almost non-existent. 🙂

flowthing20:11:23

A quick try suggests that this works just as well:

- name: Cache Maven dependencies
        uses: actions/cache@v1
        with:
          path: ~/.m2/repository
          key: maven

      - name: Cache Git dependencies
        uses: actions/cache@v1
        with:
          path: ~/.gitlibs
          key: gitlibs
https://github.com/eerohele/sigel/commit/651cd58cbda1f316dfcbf37d95f4968454572b3a/checks?check_suite_id=300964502