railsjazz / rails_live_reload

Live Reload for your Rails app. The easiest way to increase your productivity.
https://www.railsjazz.com/
MIT License
318 stars 8 forks source link

Support manually triggering a page reload from an external process #29

Open nogweii opened 9 months ago

nogweii commented 9 months ago

I am running guard on my laptop. It is monitoring changes to the files underneath config/ & lib/, and causes the whole server to restart.

I'd like to have the page reload after the server is restarted, but I'm not sure how to trigger that from something outside the rails process. Here was my first attempt at it:

require "socket"
require "json"

command = {
  "event" => "reload",
  "files" => ["app/assets/builds/application.js"]
}

socket = UNIXSocket.new("tmp/sockets/rails_live_reload.sock")
socket.puts command.to_json
manastyretskyi commented 9 months ago

Hello @nogweii, sorry for taking a lot of time to reply.

I don't think it is possible to do at the moment, for this, Unix server has to be updated here so that it will be able to receive commands from connections, as right now it can only "transmit" commands.