Hi,
I apologise if this has already been answered, but I cannot find anything relating to the topic when searching around.
I am using Rails 5.0.0.1 with ActionCable 5.0.0.1
What I am trying to achieve is creating a dashboard page, with various graphs and indicators that are updated in real time or semi-real time. I have managed to get ActionCable setup and working with a few graphs, and now I would like to use it to update a graph that shows the server load. Previously I had this working with js making a query to a controller action every second or so, which would then call a bash script, and return the results. I would like to convert this to a websocket, but I cannot find a way to do this cleanly.
What I have tried so far:
-
Create a script similar to the ones in /bin that inherit the rails environment and settings, and try to broadcast to the websocket. I realised that this doesn’t work as its creating a new instance of the app environment, so wont broadcast to the currently running rails server.
-
Create a client based off of https://github.com/NullVoxPopuli/action_cable_client, however this has the drawback that the client will also receive its own updates.
Can anyone suggest anything else that might work, or a better way to do this?
Thanks
/Cole