biff

A web framework + self-hosted deployment solution for Clojure. Repo: https://github.com/jacobobryant/biff. Docs: https://biff.findka.com
2020-11-10T02:23:10.039500Z

thanks, that worked

parenbot 2020-11-10T09:39:35.040900Z

I am having trouble getting this up and running...

prompt@prompt:~/projects/example$ ./task dev
  
   tailwindcss 1.9.6
  
   ๐Ÿš€ Building: tailwind.css
  
   โœ… Finished in 5.7 s
   ๐Ÿ“ฆ Size: 2.33MB
   ๐Ÿ’พ Saved to www/css/main.css
  
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See <http://www.slf4j.org/codes.html#StaticLoggerBinder> for further details.
Nov 10, 2020 12:37:59 PM io.undertow.Undertow start
INFO: starting server: Undertow - 2.1.3.Final
Nov 10, 2020 12:38:00 PM org.xnio.Xnio &lt;clinit&gt;
INFO: XNIO version 3.8.0.Final
Nov 10, 2020 12:38:00 PM org.xnio.nio.NioXnio &lt;clinit&gt;
INFO: XNIO NIO Implementation Version 3.8.0.Final
Nov 10, 2020 12:38:00 PM org.jboss.threads.Version &lt;clinit&gt;
INFO: JBoss Threads version 3.1.0.Final
shadow-cljs - server version: 2.11.6 running at <http://localhost:9630>
shadow-cljs - nREPL server started on port 7888
Execution error (BindException) at <http://sun.nio.ch.Net/bind0|sun.nio.ch.Net/bind0> (Net.java:-2).
Address already in use

Full report at:
/tmp/clojure-742481856711000833.edn
prompt@prompt:~/projects/example$ 

parenbot 2020-11-10T09:40:48.041Z

prompt@prompt:~$ lsof -i :8080
prompt@prompt:~$

parenbot 2020-11-10T09:41:17.041200Z

I don't seem to be having anything running on port 8080

parenbot 2020-11-10T09:42:03.041400Z

openjdk 11.0.9 2020-10-20
OpenJDK Runtime Environment (build 11.0.9+11-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.9+11-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
jason@

parenbot 2020-11-10T09:43:14.041600Z

Clojure 1.10.1

parenbot 2020-11-10T10:21:04.041800Z

I am following this guide https://findka.com/biff/#introduction

2020-11-10T10:22:20.042100Z

hm, haven't seen that problem come up before. You can use a different port by putting this in config/main.edn:

{...
 :dev {:biff.web/port 8081
       ...}}
Let me know if that works. the help message will still say "go to localhost:8080" fyi because it's hardcoded, so just ignore that

๐Ÿ‘ 1
parenbot 2020-11-10T10:22:59.042500Z

Let me try it out

2020-11-10T10:23:09.042700Z

(edited cause I see the log says ubuntu 20.04)

parenbot 2020-11-10T10:23:18.042900Z

Yep

parenbot 2020-11-10T10:25:35.043100Z

Funny, I actually do not have :biff.web/port 8081 in web dev config. Let me add it

2020-11-10T10:26:36.043300Z

that's expected; it's set to 8080 by default in the code

parenbot 2020-11-10T10:27:15.043500Z

Makes sense

parenbot 2020-11-10T10:27:53.043700Z

Looking much better...

parenbot 2020-11-10T10:28:09.043900Z

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See <http://www.slf4j.org/codes.html#StaticLoggerBinder> for further details.
Nov 10, 2020 1:26:59 PM io.undertow.Undertow start
INFO: starting server: Undertow - 2.1.3.Final
Nov 10, 2020 1:26:59 PM org.xnio.Xnio &lt;clinit&gt;
INFO: XNIO version 3.8.0.Final
Nov 10, 2020 1:26:59 PM org.xnio.nio.NioXnio &lt;clinit&gt;
INFO: XNIO NIO Implementation Version 3.8.0.Final
Nov 10, 2020 1:26:59 PM org.jboss.threads.Version &lt;clinit&gt;
INFO: JBoss Threads version 3.1.0.Final
shadow-cljs - server version: 2.11.6 running at <http://localhost:9630>
shadow-cljs - nREPL server started on port 7888

Go to <http://localhost:9630> -&gt; "Builds" -&gt; "start watch" -&gt; "Dashboard".
After the build finishes, go to <http://localhost:8080>.
Connect your editor to nrepl port 7888.
See `./task help` for a complete list of commands.

System started.

parenbot 2020-11-10T10:28:58.044100Z

Although it reports I should go to 8080. I changed the port to 8085

parenbot 2020-11-10T10:30:33.044300Z

2020-11-10T10:30:36.044700Z

Perfect. looks like it worked. that's what I meant by the message being hardcoded--I just have (println "... go to <http://localhost:8080>") in the code, it doesn't actually look at what port you used. so if you go to http://localhost:8085 you should see a sign-in form I'd also be interested to see if you can get some other program to run on port 8080, e.g. python3 -m http.server 8080

2020-11-10T10:30:38.044900Z

ah perfect

parenbot 2020-11-10T10:34:07.045100Z

Nope can't get that to work

parenbot 2020-11-10T10:34:23.045300Z

prompt@prompt:~/projects/example$ python3 -m http.server 8080
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.8/http/server.py", line 1294, in &lt;module&gt;
    test(
  File "/usr/lib/python3.8/http/server.py", line 1249, in test
    with ServerClass(addr, HandlerClass) as httpd:
  File "/usr/lib/python3.8/socketserver.py", line 452, in __init__
    self.server_bind()
  File "/usr/lib/python3.8/http/server.py", line 1292, in server_bind
    return super().server_bind()
  File "/usr/lib/python3.8/http/server.py", line 138, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/usr/lib/python3.8/socketserver.py", line 466, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

parenbot 2020-11-10T10:37:12.045500Z

I have something running on 8080

parenbot 2020-11-10T10:37:46.045700Z

parenbot 2020-11-10T10:38:11.046100Z

Doing some detective work... Thank you. ๐Ÿ™‚

parenbot 2020-11-10T10:44:07.046300Z

I think jetty server keeps restarting on 8080

tcp6       0      0 127.0.0.1:8080          :::*                    LISTEN      26610/java

parenbot 2020-11-10T10:45:24.046500Z

All good, I will keep using 8085 for now.

๐Ÿ‘ 1
ordnungswidrig 2020-11-10T11:35:31.047700Z

I tried biff and ran into this error right after generating a new project โ€œRefused to execute script from โ€˜http://localhost:8080/cljs/app/main.jsโ€™ because its MIME type (โ€˜text/htmlโ€™) is not executable, and strict MIME type checking is enabled.โ€

ordnungswidrig 2020-11-11T15:28:47.050Z

that was fast ๐Ÿ™‚

๐Ÿ™‚ 1
2020-11-10T18:02:43.048300Z

Did the cljs build finish (at localhost:9630) before you signed in? is there a file at www/cljs/app/main.js?

2020-11-10T18:05:45.048500Z

If the file isn't there, Biff would return the 404 page which would produce the error you have.

ordnungswidrig 2020-11-10T21:24:09.048700Z

Good catch. The file is missing. I had expected a 404 in the console and not a content type mismatch.

ordnungswidrig 2020-11-10T21:24:35.048900Z

I was mislead by that login page existingโ€ฆ

ordnungswidrig 2020-11-10T21:30:18.049100Z

IMHO the error in biff is that it should return a 404 if anything under /cljs/ is not found.

2020-11-10T23:02:32.049300Z

Sounds reasonable. Technically I believe it does return a 404, but the body and content type is for the html not found page, so yeah, confusing. (edit: actually I guess it would've returned a 200 with /app/index.html due to the :biff.http/spa-path option. it would've returned the 404 page in the MPA template). I think I'll add a :biff.http/asset-paths config option which defaults to #{"/cljs/" "/js/" "/css/"}. I'll also add a message to /app/index.html so instead of just Loading... , it also says something like "If you see this page for more than a second, go to localhost:9630 etc"

2020-11-10T23:03:44.049500Z

(also, you probably have figured this out already--but the login page exists since it's just a static html page, not rendered with cljs)