Skip to content

trying to get hot loader working #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
catmando opened this issue Apr 6, 2019 · 16 comments
Closed

trying to get hot loader working #435

catmando opened this issue Apr 6, 2019 · 16 comments
Assignees

Comments

@catmando
Copy link

catmando commented Apr 6, 2019

https://hyperstack.org has a built in hotloader that sets up a push notification from a task running on server, to the client.

I cant get this to work on gitpod.

after a minute or so the client throws this error:

WebSocket connection to 'wss://5000-d229dba3-3441-4622-a288-3a4990c9cc1b.ws-us0.gitpod.io:25222/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

Here is my .gitpod.yml file:

tasks:
  - init:
      bundle install
  - command:
      bundle exec rake db:create &&
      bundle exec rake db:migrate
ports:
- port: 5000
- port: 3000
- port: 9514
- port: 9515
- port: 25222

Any help is appreciated. The repo is here:

https://github.com/hyperstack-org/todo-compare use the ``gitpod`branch

for simplicity I am running in two terminal windows instead of using foreman

terminal 1: bundle exec rails s -b 0.0.0.0 -p 5000 terminal 2: bundle exec hyperstack-hotloader -p 25222 -d app/hyperstack/`

if you change a file in the app/hyperstack directoy you will see it is noticed but no message goes to the client.

The funny thing this safe app uses Rails action-cable, and that works fine!

@geropl
Copy link
Member

geropl commented Apr 6, 2019

Hi @catmando ,

on first sight your websocket URL looks bogus:
wss://5000-d229dba3-3441-4622-a288-3a4990c9cc1b.ws-us0.gitpod.io:25222.
I'll have a look at https://gitpod.io/#https://github.com/hyperstack-org/todo-compare/tree/gitpod

@catmando
Copy link
Author

catmando commented Apr 6, 2019

that is just url that the page is pointing to with a different port.
in otherwords: https://5000-d229dba3-3441-4622-a288-3a4990c9cc1b.ws-us0.gitpod.io
is the page I have loaded?

what would you expect it too look like?

@catmando
Copy link
Author

catmando commented Apr 6, 2019

FYI just double checked and works fine on my local box... i.e. I load page localhost:5000 and the hot-loader is running at wss://localhost:25222

@geropl
Copy link
Member

geropl commented Apr 6, 2019

The issues here is that hyperstack-hotloader assumes that the workspaces port 25222 is available at wss://<domain>:25222, while it actually is available at wss://25222-<workspace>:443.

I did not figure out how configure this in the hotloader, yet..

@geropl
Copy link
Member

geropl commented Apr 6, 2019

Btw, you can configure init and command to run in the same terminal like this (not tested)

tasks:
  - init:
      bundle install &&
      yarn &&
      bundle exec rake db:reset
    command: bundle exec rails s -b 0.0.0.0 -p 5000
  - init:
      bundle exec rake db:create &&
      bundle exec rake db:migrate
    command: bundle exec hyperstack-hotloader -p 25222 -d app/hyperstack/`

for instance

@catmando
Copy link
Author

catmando commented Apr 6, 2019

thanks I'll figure it out... probably have to patch hotloader, but I can do that.

@geropl
Copy link
Member

geropl commented Apr 8, 2019

Yes, looks like that would be necessary. Currently Gitpod does not support incoming traffic on other ports than 443 - thought that might change in the future. 🙂

The URL to insert there can be generated using gp url [port] like so:

gitpod /workspace/todo-compare $ gp url 25222
https://25222-f7b4807a-5ef0-458c-ac16-779595221da7.ws-eu0.gitpod.io/

@catmando
Copy link
Author

catmando commented Apr 8, 2019

thanks for the help...

I can get the hot-loader to work, but after about 90 seconds it closes the connection. Not sure why.

Again everything is posted here: https://github.com/hyperstack-org/todo-compare/tree/gitpod

and the hotloader "patch" is in app/hyperstack/components/hyper_component.rb

@catmando
Copy link
Author

catmando commented Apr 8, 2019

okay I starting pinging the websocket connection (server to client) every 10 seconds. That seems to keep it alive.

@catmando
Copy link
Author

catmando commented Apr 8, 2019

The only small thing is that when I run the hotloader using a foreman proc file after the initial hotloader message, non of the remaining messages come up.

gitpod /workspace/todo-compare $ bundle exec foreman start
19:03:35 web.1  | started with pid 10318
19:03:35 hot.1  | started with pid 10319
19:03:38 web.1  | => Booting Puma
19:03:38 web.1  | => Rails 5.1.6.2 application starting in development
19:03:38 web.1  | => Run `rails server -h` for more startup options
19:03:42 web.1  | Puma starting in single mode...
19:03:42 web.1  | * Version 3.12.0 (ruby 2.6.0-p0), codename: Llamas in Pajamas
19:03:42 web.1  | * Min threads: 5, max threads: 5
19:03:42 web.1  | * Environment: development
19:03:42 web.1  | * Listening on tcp://0.0.0.0:5000
19:03:42 web.1  | Use Ctrl-C to stop
19:04:57 web.1  | Started GET "/" for 127.0.0.1 at 2019-04-08 19:04:57 +0000

after the initial hot loader message (once puma starts?) no more hot messages come up.
Then later when you ctrl-c they all come flooding out.

@geropl
Copy link
Member

geropl commented Apr 9, 2019

I tried your example https://github.com/hyperstack-org/todo-compare/tree/gitpod and I see two websocket connection:
image

  • hotloader: 25222-...: the client sends empty frames to the server every few seconds, but never gets a response
  • actioncable websocket: 5000-...:/cable: There are two types of messages: ActionCable messages which get responses, and raw "pings" from the server, which don't get responses.

I never did ruby but will try to play around a bit.

@geropl
Copy link
Member

geropl commented Apr 9, 2019

It seems to be an issue with foreman, really. I left it out and just started two terminals and it worked nicely with your changes:
image
I created a PR against your branch: hyperstack-org/todo-compare#1

I noticed that the initial install takes some time: Gitpod has a GitHub-App that allows to "prebuild" workspaces (docs). This basically checks out your repo on each push and executes the init tasks in your .gitpod.yml. Whenever you create a workspace on that commit, you'll get a prebuilt version: all dependencies installed and generated. This service is free for public repositories.

@catmando
Copy link
Author

catmando commented Apr 9, 2019

Yes I configured hot loader to ping every 10 seconds. This seems to keep the connection alive.

The prebuild looks great can't wait to to try it.

@catmando
Copy link
Author

catmando commented Apr 9, 2019

And the pre-build works great. Thanks for the tip!

@catmando catmando closed this as completed Apr 9, 2019
@guilhermeariza
Copy link

how i can install rails on gitpod? i am lost

@jankeromnes
Copy link
Contributor

Hi @guilhermeariza, to install Rails in Gitpod, it should be enough to just run gem install rails in the Terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants