Fork me on GitHub
#off-topic
<
2021-07-07
>
Juλian (he/him)07:07:24

#lambda trending on Twitter Germany... At first I thought "yay!" but then I noticed that it's the new Corona mutation 😕

🤕 11
💀 9
😄 2
dpsutton15:07:53

if i don't know supervisord well, what's the easiest way to kick off running a jar even after the shell closes after remoting in?

nate sire16:07:02

linux screens

nate sire16:07:26

you detach (close) from the terminal an re-attach later

dpsutton15:07:18

currently there's a running tmux session which doesn't feel ideal

hiredman15:07:44

How married are you to the idea of supervisord? I use systemd user services (and I guess system systemd services too) a fair bit

dpsutton15:07:31

not married to supervisord or systemd at all. i meant i don't know it at all and would love a simpler solution

dpsutton15:07:00

don't care about OS boot. i can manually restart it. this is kind of a staging area for a long running branch and just needs to run a jar

hiredman15:07:01

`systemd-run --user --slice misc-services -u heat -G -E BS_PORT=23456 -E BS_HOST=192.168.1.160 sbcl --noinf orm --no-sysinit --no-userinit --disable-debugger --eval '(load "src/heat/control.lisp")' --eval '(some-like -it-hot:do-stuff)' ` is an example of launching a one off systemd user service, but you'll need to make a unit file for it if you want to restart on exit, etc

dpsutton15:07:04

ah, maybe systemd does make it as easy as i was hoping for

dpsutton15:07:09

fair. maybe that is a simple solution that just works. and keeps the system out in a place

tvaughan15:07:46

$ cat bin/rib
#!/usr/bin/env bash
# -*- mode: sh; coding: utf-8; tab-width: 4; indent-tabs-mode: nil -*-
set -euo pipefail
IFS=$'\n\t'

unset TMUX

tmux new-session -d -s rib-"$$" -- direnv exec "$PWD" "$@"

2
tvaughan15:07:20

Good question. I don't remember. 😞 Even though it's just two lines this has actually evolved quite a bit over the years as I found rare cases where it didn't work, e.g. adding direnv exec.

tvaughan16:07:37

I suspect this is the answer, https://stackoverflow.com/q/16398850, so rib can be run from inside a tmux session

tvaughan15:07:56

rib - run in background

nate sire16:07:38

linux screens

nate sire16:07:55

you can detach from the ssh session but it still runs

noisesmith16:07:11

tmux (discussed above) is a more advanced screen

nate sire16:07:25

I use tmux also

noisesmith16:07:46

and nohup is the most primitive version

nate sire16:07:56

not sure if tmux will keep the script running when ssh closes?

noisesmith16:07:05

yes it does

👍 5
phronmophobic16:07:14

I’ve often just run jars from a terminal in a daemonized emacsclient

phronmophobic16:07:09

emacs --daemon
emacsclient -nw
within emacs:
M-x ansi-term
$ java -jar my-uber-jar.jar

phronmophobic16:07:46

it’s not the most robust, but it’s very convenient

noisesmith16:07:38

for a portable solution there's jsvc, which can integrate on other OS (who uses anything but linux these days in prod?) I made a small convenience wrapper that lets you plug your clojure code into it without a need for AOT https://github.com/noisesmith/clj-jsvc-adapter

noisesmith16:07:09

it uses a system property to decide which namespace to load via clojure.lang.rt and run

noisesmith16:07:17

it's also the only java code I've ever published / used in prod iirc

dpsutton16:07:44

this is a jar that i can just call java -jar metabase.jar and off it goes

noisesmith16:07:31

right, but you can also put the jar on classpath and it will do the same thing with the above wrapper (and get restarted via jsvc, logged via jsvc, etc.)

noisesmith16:07:07

but there are simpler options if you don't need to run on an OS other than Linux

nate sire16:07:23

@dpsutton do you want to retry the jar if anything crashes in it?

noisesmith16:07:57

also, do you care about the program's log output? do you want to know when it crashes via any monitor?

nate sire16:07:47

example for me... an Elastic Search indexer... running all day... 32gb of ram

nate sire16:07:04

what does the jar do?

noisesmith16:07:16

another feature you may or may not want is a file indicating the process current PID

noisesmith16:07:33

and/or ensuring that only one process is running it at a time

nate sire16:07:38

this is for metabase server?

dpsutton16:07:42

would love std-out to be piped to a file for easy tailing and retention

noisesmith16:07:57

what about stderr?

noisesmith16:07:02

that's often more important

dpsutton16:07:20

fair. yeah. would love all output streams piped to a file. don't care about separating them

noisesmith16:07:25

yeah, you can of course get all of this with nohup + redirects / tee, but any good service runner removes a lot of the details you need to think about

noisesmith16:07:48

the issue with using ad-hoc things like tmux is the logs become ephemeral - eg. if the machine reboots

noisesmith16:07:06

it's really a question IMHO of what you want to support platform wise

noisesmith16:07:19

if all you need is linux, use linux - that is to say systemd

dpsutton16:07:30

oh i see the benefits of your wrapper now. i assumed i could just jsvc my-jar.jar but its not that simple

dpsutton16:07:53

yeah. i think i'll just go the systemd route. just need to figure out collecting the output

noisesmith16:07:04

jsvc offers restarts, PID monitoring, ensuring it's a singleton, log rotation and retention, etc. etc.

noisesmith16:07:11

but systemd is easier if you only need linux

noisesmith16:07:35

and it's going to capture program output in a log file out of the box right?

dpsutton16:07:37

no it logs to stdout. would need to redirect that. not sure if i can just pipe it with systemd-run or if that's an option to be set

noisesmith16:07:16

right, the wrappers all expect you to log to std(out/err) and they capture that into files

hiredman16:07:27

Sysemd-run will collect the output in the systemd journal

noisesmith16:07:35

and I would be very surprised if systemd was an exception there

hiredman16:07:42

You can query or view it via journalctl

ghadi16:07:00

❤️ journalctl

dpsutton16:07:34

i shall learn to love it as well. thanks everyone

nate sire16:07:32

archlinux 😃