From 5663e816973d835dc75afa60aea7e9e2d0c23e5d Mon Sep 17 00:00:00 2001 From: Viktor Vsk Date: Sat, 4 Apr 2026 14:32:47 +0200 Subject: [PATCH] Hotwire live-reload --- Gemfile | 2 ++ Gemfile.lock | 30 ++++++++++++++++++++++++++++++ Procfile.dev | 2 +- app/javascript/application.js | 1 + config/cable.yml | 2 +- config/importmap.rb | 1 + config/initializers/sidekiq.rb | 7 ++++++- 7 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index ef60608..b71ff6c 100644 --- a/Gemfile +++ b/Gemfile @@ -100,3 +100,5 @@ group :test do gem "capybara" gem "selenium-webdriver" end + +gem "hotwire-livereload", "~> 2.1", group: :development diff --git a/Gemfile.lock b/Gemfile.lock index 9605272..c7fcb66 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -235,6 +235,13 @@ GEM railties (>= 6.1.0) faker (3.6.1) i18n (>= 1.8.11, < 2) + ffi (1.17.4-aarch64-linux-gnu) + ffi (1.17.4-aarch64-linux-musl) + ffi (1.17.4-arm-linux-gnu) + ffi (1.17.4-arm-linux-musl) + ffi (1.17.4-arm64-darwin) + ffi (1.17.4-x86_64-linux-gnu) + ffi (1.17.4-x86_64-linux-musl) flay (2.14.3) erubi (~> 1.10) path_expander (~> 2.0) @@ -308,6 +315,10 @@ GEM temple highline (3.1.2) reline + hotwire-livereload (2.1.1) + actioncable (>= 7.0.0) + listen (>= 3.0.0) + railties (>= 7.0.0) i18n (1.14.8) concurrent-ruby (~> 1.0) i18n-tasks (1.1.2) @@ -354,6 +365,10 @@ GEM childprocess (~> 5.0) logger (~> 1.6) lint_roller (1.1.0) + listen (3.10.0) + logger + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) loofah (2.25.1) crass (~> 1.0.2) @@ -464,6 +479,9 @@ GEM railties (>= 8.0.0, < 9) rainbow (3.1.1) rake (13.3.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) rdoc (7.2.0) erb psych (>= 4.0.0) @@ -693,6 +711,7 @@ DEPENDENCIES foreman haml-rails haml_lint + hotwire-livereload (~> 2.1) i18n-tasks importmap-rails kamal @@ -795,6 +814,13 @@ CHECKSUMS factory_bot (6.5.6) sha256=12beb373214dccc086a7a63763d6718c49769d5606f0501e0a4442676917e077 factory_bot_rails (6.5.1) sha256=d3cc4851eae4dea8a665ec4a4516895045e710554d2b5ac9e68b94d351bc6d68 faker (3.6.1) sha256=c513d23c1d26b426283e913b25e0b714576011d7c1ad368a9ac6ea2113a1ccde + ffi (1.17.4-aarch64-linux-gnu) sha256=b208f06f91ffd8f5e1193da3cae3d2ccfc27fc36fba577baf698d26d91c080df + ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39 + ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564 + ffi (1.17.4-arm-linux-musl) sha256=9d4838ded0465bef6e2426935f6bcc93134b6616785a84ffd2a3d82bc3cf6f95 + ffi (1.17.4-arm64-darwin) sha256=19071aaf1419251b0a46852abf960e77330a3b334d13a4ab51d58b31a937001b + ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d + ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e flay (2.14.3) sha256=7f96a495f4bde880460e77e7345464e752bd44f09f5cd30c80af02afe0ed3f29 flog (4.9.4) sha256=12cc054fab7a2cbd2a906514397c4d7788954d530564782d6f14939dc2dfbcbb foreman (0.90.0) sha256=ff675e2d47b607ac58714a6d4ac3e1ee8f06f41d8db084531c31961e2c3f117c @@ -818,6 +844,7 @@ CHECKSUMS haml_lint (0.72.0) sha256=23acb3f5db1602eb99bccec8009372465321702e1229017cca53272957bfc9c8 hamli (0.5.1) sha256=575321dde83636a7ff5a4f0f7d9d48d59384b6388a2e2b1cfb1d8c3769a616cb highline (3.1.2) sha256=67cbd34d19f6ef11a7ee1d82ffab5d36dfd5b3be861f450fc1716c7125f4bb4a + hotwire-livereload (2.1.1) sha256=0c26a78c4d14f52e5cc52aba46b37d4a5ba12b571ddc5ed8842140aa332d5486 i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5 i18n-tasks (1.1.2) sha256=4dcfba49e52a623f30661cb316cb80d84fbba5cb8c6d88ef5e02545fffa3637a ice_nine (0.11.2) sha256=5d506a7d2723d5592dc121b9928e4931742730131f22a1a37649df1c1e2e63db @@ -831,6 +858,7 @@ CHECKSUMS language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc launchy (3.1.1) sha256=72b847b5cc961589dde2c395af0108c86ff0119f42d4648d25b5440ebb10059e lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87 + listen (3.10.0) sha256=c6e182db62143aeccc2e1960033bebe7445309c7272061979bb098d03760c9d2 logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203 loofah (2.25.1) sha256=d436c73dbd0c1147b16c4a41db097942d217303e1f7728704b37e4df9f6d2e04 mail (2.9.0) sha256=6fa6673ecd71c60c2d996260f9ee3dd387d4673b8169b502134659ece6d34941 @@ -888,6 +916,8 @@ CHECKSUMS railties (8.2.0.alpha) rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c + rb-fsevent (0.11.2) sha256=43900b972e7301d6570f64b850a5aa67833ee7d87b458ee92805d56b7318aefe + rb-inotify (0.11.1) sha256=a0a700441239b0ff18eb65e3866236cd78613d6b9f78fea1f9ac47a85e47be6e rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192 redis (5.4.1) sha256=b5e675b57ad22b15c9bcc765d5ac26f60b675408af916d31527af9bd5a81faae redis-client (0.28.0) sha256=888892f9cd8787a41c0ece00bdf5f556dfff7770326ce40bb2bc11f1bfec824b diff --git a/Procfile.dev b/Procfile.dev index eb184cd..a180f76 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,4 +1,4 @@ web: bin/rails server -p 3000 -b 0.0.0.0 css: bin/rails tailwindcss:watch -jobs: bundle exec sidekiq -c 5 +jobs: bash -c 'until bundle exec sidekiq -c 5; do echo "Sidekiq exited, retrying in 5s..."; sleep 5; done' # ws: env ANYCABLE_PORT=8081 ANYCABLE_BROADCAST_ADAPTER=redis ANYCABLE_REDIS_URL=${REDIS_URL:-redis://localhost:6379/1} ANYCABLE_RPC_HOST=http://localhost:3000/_anycable anycable-go diff --git a/app/javascript/application.js b/app/javascript/application.js index c275ea8..e239947 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,2 +1,3 @@ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails import "controllers" +import "@hotwired/turbo-rails" diff --git a/config/cable.yml b/config/cable.yml index aa7da64..bff2980 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -1,5 +1,5 @@ development: - adapter: anycable + adapter: async test: adapter: test diff --git a/config/importmap.rb b/config/importmap.rb index 29c073c..5ea735c 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -7,3 +7,4 @@ pin "three", to: "https://ga.jspm.io/npm:three@0.183.2/build/three.module.js" pin "@hotwired/stimulus", to: "stimulus.min.js" pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" pin_all_from "app/javascript/controllers", under: "controllers" +pin "@hotwired/turbo-rails", to: "turbo.min.js" diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index fb9a29f..be011c5 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -26,7 +26,12 @@ Sidekiq.configure_server do |config| "active_job" => true, } end - Sidekiq::Cron::Job.load_from_hash(cron_hash) + + begin + Sidekiq::Cron::Job.load_from_hash(cron_hash) + rescue RedisClient::CannotConnectError => e + Rails.logger.warn("Sidekiq cron: Redis unavailable, skipping schedule load (#{e.message})") + end end end end