Created
July 18, 2026 01:04
-
-
Save headius/d47f308aa54be80cfa0852e7398cc4cd to your computer and use it in GitHub Desktop.
15 minute hack attempt to remove forking from Bridgetown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/Gemfile b/Gemfile | |
| index ed7618d5..71427acf 100644 | |
| --- a/Gemfile | |
| +++ b/Gemfile | |
| @@ -7,6 +7,7 @@ gem "yard", "~> 0.9" | |
| group :development do | |
| gem "solargraph" | |
| + gem "rbs", "4.1.0.pre.2" | |
| end | |
| group :test do | |
| @@ -18,7 +19,7 @@ group :test do | |
| gem "minitest-sprint", "~> 1.4" | |
| gem "minitest-stub_any_instance" | |
| gem "nokogiri", "~> 1.7" | |
| - gem "nokolexbor" | |
| + gem "nokolexbor", platform: "ruby" | |
| gem "rack-test" | |
| gem "rubocop-bridgetown", "~> 0.6", require: false | |
| gem "simplecov" | |
| diff --git a/Gemfile.lock b/Gemfile.lock | |
| index 6cd57591..c9013c43 100644 | |
| --- a/Gemfile.lock | |
| +++ b/Gemfile.lock | |
| @@ -74,10 +74,13 @@ GEM | |
| benchmark (0.5.0) | |
| benchmark-ips (2.14.0) | |
| bigdecimal (3.3.1) | |
| + bigdecimal (3.3.1-java) | |
| bridgetown-lit-renderer (3.0.0) | |
| bridgetown (>= 2.0.0.beta6) | |
| random-port (>= 0.5) | |
| builder (3.3.0) | |
| + commander (5.0.0) | |
| + highline (~> 3.0.0) | |
| concurrent-ruby (1.3.5) | |
| console (1.34.2) | |
| fiber-annotation | |
| @@ -85,10 +88,12 @@ GEM | |
| json | |
| csv (3.3.5) | |
| date (3.5.0) | |
| + date (3.5.0-java) | |
| diff-lcs (1.6.2) | |
| docile (1.4.1) | |
| dry-inflector (1.2.0) | |
| erb (6.0.0) | |
| + erb (6.0.0-java) | |
| erubi (1.13.1) | |
| faraday (2.14.0) | |
| faraday-net_http (>= 2.0, < 3.5) | |
| @@ -99,6 +104,7 @@ GEM | |
| faraday-net_http (3.4.2) | |
| net-http (~> 0.5) | |
| ffi (1.17.4-arm64-darwin) | |
| + ffi (1.17.4-java) | |
| ffi (1.17.4-x86_64-linux-gnu) | |
| fiber-annotation (0.2.0) | |
| fiber-local (1.1.0) | |
| @@ -106,16 +112,21 @@ GEM | |
| fiber-storage (1.0.1) | |
| freyia (0.5.3) | |
| hash_with_dot_access (2.2.0) | |
| + highline (3.0.1) | |
| i18n (1.14.7) | |
| concurrent-ruby (~> 1.0) | |
| inclusive (1.1.0) | |
| io-console (0.8.1) | |
| + io-console (0.8.1-java) | |
| irb (1.15.3) | |
| pp (>= 0.6.0) | |
| rdoc (>= 4.0.0) | |
| reline (>= 0.4.2) | |
| + jar-dependencies (0.5.7) | |
| jaro_winkler (1.6.1) | |
| + jaro_winkler (1.6.1-java) | |
| json (2.16.0) | |
| + json (2.16.0-java) | |
| kramdown (2.5.1) | |
| rexml (>= 3.3.9) | |
| kramdown-parser-gfm (1.1.0) | |
| @@ -144,13 +155,21 @@ GEM | |
| uri (>= 0.11.1) | |
| nokogiri (1.19.2-arm64-darwin) | |
| racc (~> 1.4) | |
| + nokogiri (1.19.2-java) | |
| + racc (~> 1.4) | |
| nokogiri (1.19.2-x86_64-linux-gnu) | |
| racc (~> 1.4) | |
| nokolexbor (0.7.0-arm64-darwin) | |
| nokolexbor (0.7.0-x86_64-linux) | |
| observer (0.1.2) | |
| + open3 (0.2.1) | |
| ostruct (0.6.3) | |
| parallel (1.27.0) | |
| + parlour (9.1.2) | |
| + commander (~> 5.0) | |
| + parser | |
| + rainbow (~> 3.0) | |
| + sorbet-runtime (>= 0.5) | |
| parser (3.3.10.0) | |
| ast (~> 2.4.1) | |
| racc | |
| @@ -162,8 +181,12 @@ GEM | |
| psych (5.2.6) | |
| date | |
| stringio | |
| + psych (5.2.6-java) | |
| + date | |
| + jar-dependencies (>= 0.1.7) | |
| public_suffix (7.0.0) | |
| racc (1.8.1) | |
| + racc (1.8.1-java) | |
| rack (3.2.4) | |
| rack-test (2.2.0) | |
| rack (>= 1.3) | |
| @@ -176,9 +199,15 @@ GEM | |
| rb-fsevent (0.11.2) | |
| rb-inotify (0.11.1) | |
| ffi (~> 1.0) | |
| - rbs (3.9.5) | |
| + rbs (4.1.0.pre.2) | |
| logger | |
| - rdoc (6.16.0) | |
| + prism (>= 1.6.0) | |
| + tsort | |
| + rbs (4.1.0.pre.2-java) | |
| + logger | |
| + prism (>= 1.6.0) | |
| + tsort | |
| + rdoc (7.2.0) | |
| erb | |
| psych (>= 4.0.0) | |
| tsort | |
| @@ -228,27 +257,39 @@ GEM | |
| simplecov_json_formatter (~> 0.1) | |
| simplecov-html (0.13.2) | |
| simplecov_json_formatter (0.1.4) | |
| - solargraph (0.57.0) | |
| + solargraph (0.60.2) | |
| + ast (~> 2.4.3) | |
| backport (~> 1.2) | |
| benchmark (~> 0.4) | |
| - bundler (~> 2.0) | |
| + bundler (>= 2.0) | |
| diff-lcs (~> 1.4) | |
| jaro_winkler (~> 1.6, >= 1.6.1) | |
| kramdown (~> 2.3) | |
| kramdown-parser-gfm (~> 1.1) | |
| logger (~> 1.6) | |
| observer (~> 0.1) | |
| + open3 (~> 0.2.1) | |
| ostruct (~> 0.6) | |
| parser (~> 3.0) | |
| prism (~> 1.4) | |
| - rbs (>= 3.6.1, <= 4.0.0.dev.4) | |
| + rbs (>= 3.10.0) | |
| + rdoc (~> 7.0) | |
| reverse_markdown (~> 3.0) | |
| rubocop (~> 1.76) | |
| + sord (~> 7.0) | |
| thor (~> 1.0) | |
| tilt (~> 2.0) | |
| yard (~> 0.9, >= 0.9.24) | |
| yard-activesupport-concern (~> 0.0) | |
| yard-solargraph (~> 0.1) | |
| + sorbet-runtime (0.6.13342) | |
| + sord (7.1.0) | |
| + commander (~> 5.0) | |
| + parlour (~> 9.1) | |
| + parser | |
| + rbs (>= 3.0, < 5) | |
| + sorbet-runtime | |
| + yard | |
| streamlined (0.6.2) | |
| serbea (>= 2.1) | |
| zeitwerk (~> 2.5) | |
| @@ -272,6 +313,7 @@ GEM | |
| PLATFORMS | |
| arm64-darwin-24 | |
| + universal-java | |
| x86_64-linux | |
| DEPENDENCIES | |
| @@ -292,6 +334,7 @@ DEPENDENCIES | |
| nokolexbor | |
| rack-test | |
| rake (~> 13.0) | |
| + rbs (= 4.1.0.pre.2) | |
| rubocop-bridgetown (~> 0.6) | |
| simplecov | |
| solargraph | |
| diff --git a/README.md b/README.md | |
| index 0efc4402..08aeb147 100644 | |
| --- a/README.md | |
| +++ b/README.md | |
| @@ -8,7 +8,7 @@ | |
| <a href="https://www.bridgetownrb.com">Bridgetown</a> | |
| </h1> | |
| -Bridgetown is a next-generation, progressive site generator & fullstack framework, powered by Ruby. Bridgetown takes your local content and external data loaded from APIs; renders templates in Markdown, ERB, and many other formats; automatically compiles frontend assets via esbuild; and exports a complete website ready to be served by fast CDNs like Render or traditional web servers. Bridgetown also integrates closely with Roda for fullstack, dynamic web application functionality—but only when and where you need it. | |
| +Bridgetown is a next-generation, progressive site generator & fullstack framework, powered by Ruby. Bridgetown takes your local content and external data loaded from APIs; renders templates in Markdown, ERB, and many other formats; automatically compiles frontend assets via esbuild; and exports a complete website ready to be served by fast CDNs like Render or traditional web servers. Bridgetown also integrates closely with Roda for fullstack, dynamic web application functionality—b1ut only when and where you need it. | |
| [](https://github.com/bridgetownrb/bridgetown/actions?query=workflow%3Abuild+branch%3Amain) | |
| [](https://rubygems.org/gems/bridgetown) | |
| diff --git a/bridgetown-core/lib/bridgetown-core/commands/start.rb b/bridgetown-core/lib/bridgetown-core/commands/start.rb | |
| index 0e91bd9f..9e0f42ff 100644 | |
| --- a/bridgetown-core/lib/bridgetown-core/commands/start.rb | |
| +++ b/bridgetown-core/lib/bridgetown-core/commands/start.rb | |
| @@ -83,14 +83,24 @@ module Bridgetown | |
| bt_options.skip_live_reload ||= false | |
| + jruby = RUBY_ENGINE == "jruby" | |
| + | |
| build_args = ["-w"] + Array(ARGV[1..]) | |
| - build_pid = Process.fork { Bridgetown::Commands::Build[*build_args].() } | |
| + if jruby | |
| + build_pid = Thread.new { Bridgetown::Commands::Build[*build_args].() } | |
| + else | |
| + build_pid = Process.fork { Bridgetown::Commands::Build[*build_args].() } | |
| + end | |
| pid_tracker.add_pid(build_pid, file: :bridgetown) | |
| after_stop_callback = -> { | |
| say "Stopping Bridgetown server..." | |
| Bridgetown::Hooks.trigger :site, :server_shutdown | |
| - Process.kill "SIGINT", build_pid | |
| + if jruby | |
| + Thread.kill build_pid | |
| + else | |
| + Process.kill "SIGINT", build_pid | |
| + end | |
| pid_tracker.remove_pidfile :bridgetown | |
| # Shut down the frontend bundler etc. if they're running | |
| diff --git a/bridgetown-foundation/lib/bridgetown/foundation/packages/pid_tracker.rb b/bridgetown-foundation/lib/bridgetown/foundation/packages/pid_tracker.rb | |
| index a4c56926..62830451 100644 | |
| --- a/bridgetown-foundation/lib/bridgetown/foundation/packages/pid_tracker.rb | |
| +++ b/bridgetown-foundation/lib/bridgetown/foundation/packages/pid_tracker.rb | |
| @@ -4,21 +4,36 @@ module Bridgetown::Foundation | |
| module Packages | |
| module PidTracker | |
| def create_pid_dir | |
| - FileUtils.mkdir_p pids_dir | |
| + if RUBY_ENGINE != "jruby" | |
| + FileUtils.mkdir_p pids_dir | |
| + end | |
| end | |
| def add_pid(pid, file:) | |
| - File.write pidfile_for(file), "#{pid}\n", mode: "a+" | |
| + if RUBY_ENGINE == "jruby" | |
| + @threads ||= {} | |
| + @threads[file] == pid | |
| + else | |
| + File.write pidfile_for(file), "#{pid}\n", mode: "a+" | |
| + end | |
| end | |
| def read_pidfile(file) | |
| - File.readlines pidfile_for(file), chomp: true | |
| + if RUBY_ENGINE == "jruby" | |
| + @threads[file] | |
| + else | |
| + File.readlines pidfile_for(file), chomp: true | |
| + end | |
| rescue SystemCallError | |
| [] | |
| end | |
| def remove_pidfile(file) | |
| - File.delete pidfile_for(file) | |
| + if RUBY_ENGINE == "jruby" | |
| + @threads.delete file | |
| + else | |
| + File.delete pidfile_for(file) | |
| + end | |
| rescue SystemCallError # rubocop:disable Lint/SuppressedException | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment