Fork me on GitHub
#biff
<
2022-12-11
>
Jacob O'Bryant00:12:51

just skimmed this, and it sounds like this might be handy for developing-in-prod with biff? if i understood it correctly it sounds like you could just install a cli utility on the server and you're good to go, no need for rsync-on-save. I assume VS code handles stuff so there's no lag when editing files like there would be over eg plain ssh https://code.visualstudio.com/blogs/2022/12/07/remote-even-better

Jacob O'Bryant00:12:28

if so, this would make biff fully supported on plain windows (as long as you use VS code) since develop-in-prod is the only thing that doesn't work there

Mario Trost14:12:01

👋 I wanted to continue with the tutorial today, https://biffweb.com/docs/tutorial/deploy/, bb logs gives me

Dec 11 14:37:16 ubuntu-s-1vcpu-1gb-fra1-01 sh[1074]: Type:     java.lang.Exception
Dec 11 14:37:16 ubuntu-s-1vcpu-1gb-fra1-01 sh[1074]: Message:  File does not exist: run-cmd
Dec 11 14:37:16 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1]: app.service: Main process exited, code=exited, status=1/FAILURE
Dec 11 14:37:16 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1]: app.service: Failed with result 'exit-code'.
Dec 11 14:37:21 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1]: app.service: Scheduled restart job, restart counter is at 6.
Dec 11 14:37:21 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1]: Stopped app.
Dec 11 14:37:21 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1]: app.service: Start request repeated too quickly.
Dec 11 14:37:21 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1]: app.service: Failed with result 'exit-code'.
Dec 11 14:37:21 ubuntu-s-1vcpu-1gb-fra1-01 systemd[1]: Failed to start app.
Did anyone else run into this?

Jacob O'Bryant16:12:42

I think I ran into this bug and fixed it. what version of biff was your project created with?

Jacob O'Bryant16:12:45

(I've been thinking of trying out Fly with Biff instead of digitalocean, and it occurs to me that this would be another advantage of doing so: it'd be easy for me to push out upgrades to the production environment/setup along regular biff releases)

Mario Trost16:12:16

{:paths ["src" "resources" "target/resources"]
 :deps {com.biffweb/biff {:git/url "" :sha "6353c406adef0344484b49a5ef2282eab77c2347"}
        camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"}
        org.slf4j/slf4j-simple {:mvn/version "2.0.0-alpha5"}}}

Jacob O'Bryant16:12:32

the relevant line is here: https://github.com/jacobobryant/biff/blob/9c11643516e8526a75c761f77139014241d5f114/example/setup.sh#L63 bb run-cmd is supposed to return a shell command that starts with clj .... the command should be defined in the /home/app/bb.edn file on the server, here: https://github.com/jacobobryant/biff/blob/9c11643516e8526a75c761f77139014241d5f114/example/bb.edn#L15 that error message makes it looks if the run-cmd isn't actually defined in the bb.edn file, and thus bb tries to look for a run-cmd file (which doesn't exist, as expected)

1
Jacob O'Bryant16:12:52

I'll take a look at that commit

🙌 1
Mario Trost16:12:19

Thanks a lot!

👌 1
Mario Trost16:12:07

And funny you mention fly: When I started the deploy chapter I thought about trying it out on fly or asking here if anyone tried it

Mario Trost16:12:10

But I only ever ssh'd into fly apps with fly ssh <appname> and concluded it wouldn't work as is

Mario Trost16:12:22

But especially fly machines ability to scale to zero would make it very attractive for tutorials/costs

Jacob O'Bryant16:12:11

hm, well that commit has all the up-to-date code around deployment. so it's possible that there's still a bug in there. could you ssh into the server (`ssh app@...`) and paste output of cat bb.edn? and try running bb run-cmd as well

Jacob O'Bryant16:12:56

yeah, it'll need a bit of work to get it working on fly--mainly need to convert (parts of) the setup.sh script into a dockerfile.

Mario Trost17:12:22

Okay strange, when I ssh into app@... I don't have a bb.edn

Mario Trost17:12:03

config.edn, repo.git and target , nothing else

Mario Trost17:12:44

I'm off now making dinner and won't be at the computer again today, so no hurry at all from my side.

👍 1
Mario Trost17:12:50

Thanks again!

Jacob O'Bryant17:12:52

have you ran bb deploy? that would explain the files not being there. though I'm surprised config.edn is there if you haven't ran bb deploy yet. maybe the deploy command failed partway through

Jacob O'Bryant17:12:18

I'll try going through that part of the tutorial again myself

Jacob O'Bryant17:12:09

do you remember if there was any error output?

Mario Trost17:12:58

I didn't see anything

Mario Trost17:12:05

I make a small change and run it again

👍 1
Mario Trost17:12:40

Looks okay:

Rebuilding...

Done in 138ms.
Everything up-to-date
"Elapsed time: 497.944958 msecs"

Jacob O'Bryant17:12:53

that looks like there wasn't a new commit to push so it skipped the deploy

Jacob O'Bryant17:12:07

maybe add a blank line to bb.edn and commit, then deploy? no need to do it right now though :)

Mario Trost17:12:11

again:

Rebuilding...

Done in 138ms.
Everything up-to-date
"Elapsed time: 498.238792 msecs"

Mario Trost17:12:48

I guess something went wrong with the setup.sh script, then?

Mario Trost17:12:56

But yeah: Off for now, thanks again 😄

Jacob O'Bryant17:12:45

well that's just weird I'll give you some more things to try later, unless I find the problem on my own!

Jacob O'Bryant21:12:22

I haven't tested the deploy process again yet, however the tutorial app was written with a version of biff two commits behind the one you're on, and there's nothing in those two commits that would affect deploys. (And I did deploy the tutorial app successfully when I was working on it.) That Everything up-to-date message is really fishy. The bb deploy command is just doing a plain git push basically. If you've made a new commit, then... it really should be pushing something ha ha. Perhaps triple-check that you made a new commit? What's the output of git log? If that's all in order, next thing I'd check is the :tasks section of config.edn, specifically the values of :biff.tasks/deploy-from, :biff.tasks/deploy-to, and :biff.tasks/server. and also output of git remote -v -- make sure everything matches up. In any case you should be able to make a new commit, type git push prod master , and have it actually do something.

Jacob O'Bryant21:12:24

Alternatively, you can just go ahead with the rest of the tutorial (you can do it all locally, no need to have anything in production), and I'm planning to work on Fly stuff next anyway 🙂

Mario Trost11:12:54

👍 Thanks again, I'm gonna check again this evening (European time) and let you know. I guess I made a mistake somewhere, but if I can't find anything I just go ahead without the prod deployment

👍 1
Mario Trost07:12:42

Yes, I'm on mac

Mario Trost07:12:28

Output of which systemctl in the droplet:

/usr/bin/systemctl

Jacob O'Bryant22:12:36

hm. and cat /etc/sudoers.d/restart-app shows the same as what I pasted above? If you do ssh app@<server> and then sudo systemctl restart app does that work? If it does work, then I wonder if the sudoers file just wasn't taking effect until after a reboot or something. I thought I observed that not being the case, but I might be mistaken.

Mario Trost19:12:44

Looks like it:

app ALL= NOPASSWD: /bin/systemctl reset-failed app.service
app ALL= NOPASSWD: /bin/systemctl restart app
app ALL= NOPASSWD: /usr/bin/systemctl reset-failed app.service
app ALL= NOPASSWD: /usr/bin/systemctl restart app

Mario Trost20:12:11

sudo systemctl restart app doesn't seem to work and now I receive 502 nginx Bad Gateways error 😄 Doesn't matter, I continue with the tutorial as it is

👌 1
Jacob O'Bryant22:12:24

hm! well it seems the sudoers file isn't taking effect for some reason. Not sure why that would be happening.

Jacob O'Bryant03:12:39

So, this should be fixed now... it was failing because I typed resart instead of restart in the bb task :face_palm: https://github.com/jacobobryant/biff/pull/144

😄 1