Fork me on GitHub
#portal
<
2020-10-17
>
djblue17:10:18

This is really dope, thanks for sharing!

borkdude17:10:07

Enjoyed the video :)

❤️ 3
nate18:10:19

Portal is very cool. I'm going to try using it when I need a data explorer. One hiccup I'm having is that it opens on a random port. I do all my development remotely and use ssh port forwards, so each time I launch portal, they need to be adjusted. I looked through the source and it doesn't look like I can specify a port. Would you be up for a PR adding port as a config option?

djblue19:10:36

That sounds good to me. What name did you have in mind for the config key?

djblue19:10:58

I think it should be fully qualified, but that's all I got

djblue19:10:01

:portal.server/port ?

nate19:10:49

Yeah, that sounds good. Or :portal.expose/port

nate19:10:10

Or trade expose for ui

djblue19:10:45

I think that could work. What other keys could you see under that ns?

nate19:10:15

host in case not accessed over local host. And maybe launch-command for specifying something other than chrome.

nate19:10:25

Those are the only that come to mind.

djblue19:10:47

I think I might like :portal.launcher/port :portal.launcher/host and :portal.launcher/command then 👌

nate19:10:35

Those sound great.

djblue19:10:50

I don't think we need to implement them all right now, :portal.launcher/port alone would be an awesome add!

djblue19:10:04

Let me know if you need any help with the code

nate19:10:20

Cool. Thank you.

borkdude19:10:30

I might have a similar problem with an upcoming feature for babashka pods: instead of stdin/stdout pods can choose to use a socket for communication and by default, the pod will choose a random open port (this is for pods that want to have full control over the terminal, e.g. TUI)

👌 3
borkdude19:10:39

@U0510902N random ports usually go in the higher area > 10000 I think? it would be highly co-incidental if that would conflict with one of your pre-configured ssh tunnel ports?

nate19:10:51

The problem I run into isn't that portal's ports conflict with my already-forwarded ports, but that in order to access the portal port, I have to make a new port forward. When I can specify the portal port, I'll set my forwarding to include a few well chosen ports and just use one of those when opening portal.

👌 3
nate19:10:46

Your idea about using a socket for pod communication sounds really cool. As does a lanterna pod.

borkdude19:10:12

Ah right. So there's no need for me to make the port of the pod configurable then I guess?

borkdude19:10:53

The lanterna pod can already run console-tetris

🎉 9
nate19:10:53

Yes, indeed.

nate16:10:49

@U1G869VNV PR opened. Had a couple questions too in the comments https://github.com/djblue/portal/pull/19

👀 3
djblue17:10:01

@U0510902N to your second question, maybe we can have a lower level api that is only available for server backed rpc implementations. Like first you (portal.launcher/start host port) , then you (portal.api/open) as many times as you like? I think it's simpler but definitely not as easy 😬

nate17:10:12

ah, that makes a lot of sense

nate17:10:53

so if you call (portal.api/open), you get the default behavior and if you want to specify the host/port, then you need to run (portal.launcher/start host port) first?

djblue17:10:31

That's my thinking, would that be reasonable?

nate17:10:42

I think so

nate17:10:23

and would this only be necessary for the jvm and node launchers?

👍 3
djblue17:10:14

I guess it could also be portal.api/start

djblue17:10:38

With a description about how it's a low level thing that you only need to care about if you want control over the server

nate17:10:11

yeah, portal.api/start sounds good

nate17:10:22

I'll update the PR with this later

djblue17:10:33

Sounds great, thanks!

nate17:10:44

you're welcome, thank you for the feedback

nate16:10:31

@U1G869VNV I was working on this yesterday morning and realized that only port is unchangeable (and should be passed to the start function). host is something that can be different on each open call. Is it confusing to have :portal.colors/theme and :portal.launcher/host as options for open and only honor :portal.launcher/port in start?

nate16:10:47

the tricky part about making start the way to override host is that it's not an attribute of the server, so I would need to store it in the atom as well so that open can use it

nate16:10:13

I'm leaning toward host and port being just for start, because that seems less confusing, thoughts?

djblue16:10:00

@U0510902N I agree, keeping those options for start now seems best

nate16:10:49

cool, thank you

💯 3
nate00:10:03

Apologies on the delay in getting this done, work rather exploded this week. I should have some time on Saturday to get the PR updated.

👌 3
nate03:10:08

@U1G869VNV I just pushed a commit that separates out the a new start function. I'm sure of the JVM launcher code. I'm less sure of the Node launcher code as I was only able to test it by running the node sample (I couldn't connect my editor to the repl and start/stop, but I was able to stop via the actual REPL prompt). Please let me know what you think of the code and if there's anything I should change. Thank you.

djblue03:10:24

@U0510902N, to test different environments, I use make e2e . It looks like you might have missed fixing p/close for node. You can run make e2e/node specifically to run those tests.

djblue03:10:14

The main issues I'm seeing is that the node process isn't terminating which probably means the server is still running.

djblue03:10:06

diff --git a/src/portal/runtime/node/launcher.cljs b/src/portal/runtime/node/launcher.cljs
index 05f89fe..80926b9 100644
--- a/src/portal/runtime/node/launcher.cljs
+++ b/src/portal/runtime/node/launcher.cljs
@@ -47,14 +47,12 @@
 
 (defn start [options]
   (when (nil? @server)
-    (reset!
-     server
-     (a/let [{:portal.launcher/keys [port host] :or {port 0 host "localhost"}} options
-             server (create-server #'server/handler port host)]
-       server))))
+    (a/let [{:portal.launcher/keys [port host] :or {port 0 host "localhost"}} options
+            instance (create-server #'server/handler port host)]
+      (reset! server instance))))
 
 (defn- stop [handle]
-  (some-> handle :http-server (.close)))
+  (some-> handle :http-server .close))
 
 (defn open [options]
   (let [session-id (random-uuid)]

djblue03:10:46

@U0510902N ☝️ should fix it. a/let returns a promise

nate05:10:33

Ah! Ok. Thanks for that. I'll add that and run the e2e tests.

nate17:10:40

@U1G869VNV I just pushed up the above code change as a commit. Looks like the jvm, bb, and node e2e tests run well. I can't get e2e/web to work.

djblue17:10:03

You might have to enable pop-ups but it's fine, everything looks good to me locally.

djblue17:10:34

@U0510902N I just merged the PR, thanks! I should have a release out in the next couple of days.

nate17:10:34

awesome, thank you for merging

nate17:10:43

and thank you for your feedback during the process

👍 3