How to show allocated host+port in Info card?

Hi,

We have Open OnDemand App that when launched opens web browser in a Desktop with host+port URL generated when the job starts.
We want to have this URL available in the Info card, so researchers can reopen the URL if they close the browser in the App.

When the App starts, the Host name is shown in the Info card.
However, I haven’t been able to add the port to the Info card, nor access the Host information after it is generated.

I do export the port in before.sh.erb and define it as conn_params in submit.yml.erb, but I am not able to access these values in info.html.erb.

We use VNC template for this App, so we can not have view.html.erb.

Can you please let me know how I can achieve this and have the dynamic URL as part of the Info card?

We have Open OnDemand 2.0.32 on our cluster.
Please let me know if you need any additional information.

Thank you,
Natasha

I was able to get this to run by using the connect API. Here’s what I did.

# made it here!
<p><%= connect.host %></p>
<p><%= connect.port %></p>

However, that said, I think you likely want to define a new thing like app_port and use it as port is special to us and it is the port that noVNC connects to.

So you set and export the variable in before.sh.erb

export app_port=$(find_port)

Add it to the conn_params and you should be able to reference it through connect.app_port.

Though I shoul note that you’ll see something like this when the app hasn’t started yet, which is normal - there’s no file to read yet so it throws this error. It will display the error until the job is actually running and has written the connection.yml.


d

Thank you for the prompt reply Jeff!

I actually got that error, so I was gonna ask you about it :slight_smile:

Is there a way to bypass the error, have a dummy empty connection.yml file or have it delayed with after.sh.erb maybe ?
I am worried that researchers using the App won’t know that that Error message can be ignored.

Thank you,
Natasha

I might have said no - but your idea for a dummy empty connection.yml will do just the trick.

Do this in your app’s root directory and when the job launches it’ll see this empty erb file, render it (well, try to, it’s empty) and place the empty connection.yml in the right location. The job will overwrite it when it does it’s thing.

touch template/connection.yml.erb

Thank you Jeff!

The empty connection.yml.erb file worked regarding the error from above.

However, that caused a different issue for me.
The App starts a server that takes a while to start, so I have:

timeout 30
echo "Waiting for Server to open port ${app_port}..."

in after.sh.erb such that the Launch App button appears after the server starts (otherwise it shows black screen when the button is clicked and that may cause another confusion for researchers using the App).

By adding the empty connection file, the Launch App button is shown before the App server is started which is causing the same issue I had before adding timeout in after.sh.erb.

Is there a way for me to have these two separate things solved at the same time, or I can only have one at the time?

Thank you,
Natasha

:man_facepalming: Sorry, no I don’t think so.

Well actually, maybe in the info.html.erb you can check for the file first. So you provide an if block to check for the file and if its’ there, then you render connect.app_port.

if File.exist?()
  show the port
end

Jeff, thank you, thank you, so much!

Checking for the connection.yml File in info.html.erb did exactly what I wanted - the host and port are shown in the Info card after the session starts, and the Launch App button is shown when the server starts as well.

Thank you always for the prompt and great support!

Thank you,
Natasha

1 Like